cancel
Showing results for 
Search instead for 
Did you mean: 

Wrap text in double quotes when generating a csv file

Former Member
0 Kudos

In the receiver communication channel, how do I put double quotes around the text fields for a CSV file output?

This is what I have in my file content conversion parameters:

<Structure>.addHeaderLine 0

<Structure>.fieldSeparator ,

<Structure>.enclosureSign "

<Structure>.enclosureSignEnd "

<Structure>.enclosureConversion YES

<Structure>.endSeparator 'nl'

I don't think I'm using the enclosureSign and enclosureConversion correctly because this configuration is not putting double quotes around the text fields in the CSV file output. Your help is much appreciated. Thanks!

Accepted Solutions (0)

Answers (3)

Answers (3)

Shabarish_Nair
Active Contributor
0 Kudos

>

> In the receiver communication channel, how do I put double quotes around the text fields for a CSV file output?

>

> This is what I have in my file content conversion parameters:

> <Structure>.addHeaderLine 0

> <Structure>.fieldSeparator ,

> <Structure>.enclosureSign "

> <Structure>.enclosureSignEnd "

> <Structure>.enclosureConversion YES

> <Structure>.endSeparator 'nl'

>

> I don't think I'm using the enclosureSign and enclosureConversion correctly because this configuration is not putting double quotes around the text fields in the CSV file output. Your help is much appreciated. Thanks!

Please note that the parameters enclosureSign and enclosureConversion etc are only for the sender adapter and will not work for the receiver file adapter.

in your case you will have to handle the double quotes as part of your mapping.

So when you map the required target text fields in the mapping, use a UDF or a simple concat logic to add quotes at the beginning and end of the value.

simple UDF logic;

//suppose your input to the  UDF is input

String quotes = "\"";
String endresult = quotes + input + quotes;
return endresult;

Former Member
0 Kudos

I created a user defined function in the message mapping to add the double quotes and it worked.

public String addQuotes(String a,Container container){

if(a != null && a != ""){

a = "\"" + a + "\"";

}

return a;

Thanks to everyone for all your help!

former_member206760
Active Contributor
0 Kudos

Kristine ,

What i would suggest is you add the " that you want for every field in the graphical mapping

Former Member
0 Kudos

Did you mean add the double quotes manually as a constant from the message mapping?

former_member206760
Active Contributor
0 Kudos

yes kristine,

you got me right. you can manipulate the way u want....put " at start / end wherever using graphical mapping

Edited by: Tarang Shah on Mar 20, 2009 7:40 AM

Edited by: Tarang Shah on Mar 20, 2009 7:41 AM

former_member181985
Active Contributor
0 Kudos

try like this........\"

Former Member
0 Kudos

Changing it to \" didn't work.

<Structure>.addHeaderLine 0

<Structure>.fieldSeparator ,

<Structure>.enclosureSign \"

<Structure>.enclosureSignEnd \"

<Structure>.enclosureConversion YES

<Structure>.endSeparator 'nl'