I have an issue to parse a CSV file with the following separator ';' and quote char '"'.
The problem is that I have to deal with quotes and semicolons inside the quoted string.
I cannot change the source file / separators etc.
I am using the library com.opencsv version 5.6 to parse the CSV.
CSV file:
"Col1";"Col2";"Co"l3""";"Col; Col"
Expected parsing result:
- Position 1: Col1
- Position 2: Col2
- Position 3: Co"l3"
- Position 4: Col; Col
This is the parser:
CSVParser parser = new CSVParserBuilder()
.withSeparator(';')
.withQuoteChar('"')
.withIgnoreQuotations(true)
.build();
This is result:
- (ok) Position 1: Col1
- (ok) Position 2: Col2
- (ok) Position 3: Co"l3"
- (error) Position 4: Col
- (error) Position 5: Col
The parser is treating well the quotes inside the quoted string, but is wrongly splitting the last element.
P.S. : If I don't use "with Ignore Quotations" an exception is thrown.
Could you please help me on solve this issue?
Thanks