Two Stars

how add double quotation to a column?

Hi everyone,

 

I need to add double quotation to a column which will be exported into a csv.

I just saw that the component tFileOutDelimited has an option for text enclosure but there I can't

select the right column it will put double quotes on all my column values.

 

Let's say the column is called product description.

The string is something like: abc wheel size 16"

Which component do I need that the csv will show "abc wheel 16" "?

Do I have to replace the double quote on 16 inside the string  so that a csv parser is able to know that this is not the end of the string?

 

Thanks for any tips.

  

4 REPLIES
Community Manager

Re: how add double quotation to a column?

Hi
If you just want to add double quote to one column, do it on tJavaRow or tMap, eg:
tfileinputDelimited--tJavaRow--tFileOutputDelimited
...other columns...
output_row.columnName="\""+input_row.columnName+"\"";

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Seven Stars

Re: how add double quotation to a column?

Hi pawe84,

 

We can use StringHandling.DQUOTE("Hello") function in talend to put double quotation for a string.

Thanks & Regards
A Ravi Kumar
Mobile Number : +91 852-762-1083
Email-id : a.ravikumar104@gmail.com
Skype Id : ammanannaravikumar
Two Stars

Re: how add double quotation to a column?

Nice but what about the double quote inside a string? Will it be escaped?

 

Inside the csv I need this pattern e.g.    wheel size 24"" that the parser is able to convert it into: wheel size 24"

Six Stars

Re: how add double quotation to a column?

I took this as an example:


ID,NAME,DESCR
1,TITU,Titu wheel size 16"

and pass this to tFileOutputDelimited as FilName.csv with field separator ",".
After running the job, it will show the record as it is (TITU,Titu wheel size 16") with double quotes at the end.
No need to use CSV option in AdvanceSettings.

 


Regards,
Mohit