I'm using apache commons.csv.CSVparser. I want to use a String array in a csv record for instance:
"\"[\"54bb051e-3d12-11e5-91cd-b8f6b11b7feb\",\"472a9748-3d12-11e5-91cd-b8f6b11b7feb\"]\",Hallo,114058,Leon,31,\" \",8400,bar,FOO";
CSVParser csvParser = CSVFormat.DEFAULT
.withDelimiter(CSV_SEPARATOR).withQuote(null)
.withFirstRecordAsHeader()
.parse(new StringReader(line));
How to escape the comma in the String[] array? After the record is readin the Strings get split into a java array.
I tried this:
@Test
public void processLine() throws Exception {
String line = "Ids,Info.name,Info.number,address.street,address.number,address.bus,address.postalcode,address.city," +
"address.country\n" +
"\"[\"\"54bb051e-3d12-11e5-91cd-b8f6b11b7feb\"\",\"\"472a9748-3d12-11e5-91cd-b8f6b11b7feb\"\"]\",Hallo,114058,Leon,31,\" \",8400,foo,BAR";
CSVParser csvParser = CSVFormat.DEFAULT
.withDelimiter(CSV_SEPARATOR).withQuote(null)
.withFirstRecordAsHeader()
.parse(new StringReader(line));
The comma of the String[] still been seen as a delimiter.