You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jean Francois LE BESCONT <jf...@gmail.com> on 2013/05/23 16:38:51 UTC

Marshal with quote in CSV

Hi,

I have found a strange behavior with the bindy in CSV.

It is said in the doc that :

Notice that if you want to marshal from Object to CSV and use quotes, then
you need to specify which quote character to use, using the quote attribute
on the @CsvRecord as shown below:

@CsvRecord( separator = ",", quote = "\"" )public Class Order {
...
}


I a simple exemple :

@CsvRecord(separator = ";" , quote = "\"" )
public class Ticket {

@DataField(pos = 1, required = true)
public String TCK_TYPE1;

 @DataField(pos = 2, required = true)
public String TCK_TYPE2;
}
With a file :
[...]
1;A 2;"B;2"
[...]

A simple processing which take the input file and write in other directory
after binding :

from("file://C:/Temp/camel/rep1/?noop=true") .split()
.tokenize("\n").streaming() .unmarshal().bindy(BindyType.Csv, Ticket.class)
.marshal().bindy(BindyType.Csv, Ticket.class)
.to("file://C:/Temp/camel/rep1/out/?fileName=out.csv&charset=utf-8&fileExist=Append")
.end();



Write an output without quote caracter, output file looks:
[...]
1;A
2;B;2
[...]

Bad no ?

Thanks

Jeff