Four Stars

Escape character CSV

Hello in Tmap I have :

"{" + '"' + row1.statut + '"' + "}"

But in my CSV in row I have :

"Test","{""in use""},"2","3"

I need a csv structure :
But for the row i don't need double quote ""

i want :

"Test","{"In use"},"2","3"

Thanks !!
Ten Stars

Re: Escape character CSV

I'm going to assume the relevant value is meant to be: "{"in use"}" as having a leading quote but no trailing quote is going to cause problems.


Talend is escaping the inner quotes so whatever reads the file treats them as data and not string enclosures.  If you want the raw output to look like "{"in use"}" turn off CSV options on your output component and manually wrap your values in quotes.  Otherwise, tFileOutputDelimited is going to require an Escape Character value, and is going to escape inner quotes in your strings.


Out of curiosity, what program or process is going to read your output file that you don't want to escape your quotes?


Four Stars

Re: Escape character CSV

I don't understand who wrap manuelly the value with quotes in tmap ?
I have to keep the quotation marks because from time to time a value of a column may contain commas that disrupts the import because it gives different columns
Ten Stars

Re: Escape character CSV

You have quotation marks as data in a csv file where values are wrapped in quotes.  This requires a way to differentiate between quotes wrapping values and quotes that are part of data values-- usually handled by escaping the data quotes.  Standard ways of escaping quotes are to double them when they're data quotes or to place an escape character in front of a data quote.  Which method you choose depends on what you're going to do with the csv file after you produce it.

Four Stars

Re: Escape character CSV

In the input CSV I have:


"TEST","In use","Solaris, Windows","les serveur "entrees" sont","trois"


So there are commas or double quotes in the data.
In output I am obliged to have a structure:


 "TEST","In use","Solaris, Windows","les serveur "entrees" sont","{"In use"}"


To properly integrate the real encapsulated data between ," ",


You understand ?

Ten Stars

Re: Escape character CSV

The last two tokens are not properly encapsulated as there's nothing to indicate that the inner quotes are not a text enclosure. If you need to create an output string exactly like this, you're going to have to construct it yourself. Otherwise, the tFileOutputDelimited component is going to try to escape the inner quotes in some manner.