Reputation: 195
My csv values are separated as follows:
number, "This is a string, that has comma", foo, bar
This is my csv reader:
CsvToBean<MyObject> csvToBean = new CsvToBeanBuilder<MyObject>(reader)
.withType(MyObject.class)
.withIgnoreLeadingWhiteSpace(true)
.withSeparator(',')
.withIgnoreQuotations(true)
.withSkipLines(1)
.build();
which actually results in these values:
number
This is a string
that has comma
foo
bar
What I really want is:
number
This is a string, that has comma
foo
bar
I tried to look through other questions from the website, but it seems they are not similar to my issue. So how can I separate values by commas outside double quotes only and also ignore the double quotes?
Upvotes: 2
Views: 2564
Reputation: 195
It seems that I only need to remove the ignore quotations line and it works fine:
CsvToBean<MyObject> csvToBean = new CsvToBeanBuilder<MyObject>(reader)
.withType(MyObject.class)
.withIgnoreLeadingWhiteSpace(true)
.withSeparator(',')
//.withIgnoreQuotations(true)
.withSkipLines(1)
.build();
Upvotes: 2