How do I preserve newline characters embedded in text field?

One Star

How do I preserve newline characters embedded in text field?

I've seen a few posts on this but I have not seen a definitive solution. I am extracting data from a SQL Server database that comes from a product service desk. Several of the fields in SQL Server have text in them with carriage returns and line feeds embedded. When I extract the data with Talend into a text file, the embedded new line characters cause new lines in the data output files which is not the desired result. My requirement from my users is that I do not strip these new lines out of the data extract. What do I need to do in Talend to ignore the embedded new lines and carriage returns within a field? I'm using Talend Open Studio 5.2.1 and am a relatively new user. I'm separating my fields with pipes: "|".
One Star

Re: How do I preserve newline characters embedded in text field?

Did you ever get a resolution with this. I have the same issue. I know I can do a search an a replace so it doesn't create the new line, but I need to preserve it in the CSV.
Moderator

Re: How do I preserve newline characters embedded in text field?

Hi camdebuck,
Did you ever get a resolution with this. I have the same issue. I know I can do a search an a replace so it doesn't create the new line, but I need to preserve it in the CSV.

Could you please elaborate your case with an example with input and expected output values?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Seventeen Stars

Re: How do I preserve newline characters embedded in text field?

You could enclose your fields with a ". If a field which is enclosed within double quotas, the new line chars will be ignored by CSV readers even if it looks terrible because of the line breaks.
example you have 3 columns COL1, COL2, COL2 and COL2 contains line breaks:
"123"|"This is
content with a line break"|"blablabla"
This 2 lines will be parsed as ONE line because the line break is within the quotas.
One Star

Re: How do I preserve newline characters embedded in text field?

Hi Team,
Same issue faced here. Me also trying to pull data from MS SQL server and have embedded new line characters at the end of few fileds. What my requirement is , to generate and upload one csv file with the extract into S3 and eventually ccopy the data into Redshift DB.
The content of the sql src is mostly Chinese and facing other issues as well and this is the new one just facing today.
 
Please let me know if any solution is there for the same.