cancel
Showing results for 
Search instead for 
Did you mean: 

Remove CRLF from the text file

groverarena
New Contributor

Hi,
What should I add to this to remove CR and LF while generating a text file using File Writer .

“Test/Hello_”+ Date.now().toLocaleDateString(‘{“format”:“MMM”}’).toUpperCase()+Date.now().toLocaleDateString(‘{“format”:“YYYY”}’)+“.txt”

9 REPLIES 9

Add mapper after csv formatter , change view of mapper from document to binary for both input and output view, in then use $content.replaceAll(’\r\n’, ‘’) syntax .Make target filed as $content, it will work.

groverarena
New Contributor

Here is the error after ,making the changes you’ve suggested.
image

Don’t know whether you tried what happens if mapper is before formatter, if so what is the outcome?

@groverarena Ok, before mapper use binary to document and make encoding none. Then use the suggested syntax.Make sure input view of the mapper should be document and the content type should suggest as String then it should work.

del
Contributor III

@groverarena, I didn’t understand your question entirely.

Are you trying to remove all \r\n from the CSV Formatter output (which is the row delimiter and would bring all the rows into a single row for the file), or are you trying to remove all \r\n from only field data coming from the SQL output (while keeping row delimiters in place for a valid CSV file)?

If it is the latter case, you can add a mapper between the SQL Execute and CSV Formatter with the following configuration. This will check all the values coming out of SQL Execute, and replace \r\n with an empty string.

image