camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean Francois LE BESCONT <jflebesc...@gmail.com>
Subject Marshal with quote in CSV
Date Thu, 23 May 2013 14:38:51 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message