commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Андрей <andreykuliko...@gmail.com>
Subject [csv] Two qoute characters in a row cause error
Date Wed, 11 Nov 2015 07:44:58 GMT
Hello everyone,

I've recently noticed a some bug, I suppose. I have the following csv 
file (2 lines):

DATA_SERVICE_ID,""DATA_SPEED_APID"",COMPONENT_ID,SPEED,SYNCHRONOUS
2120000,""1596"",4240000,9600,true

(The first line is a header)

I'm trying to parse it via this configuration:
CSVFormat format = CSVFormat.newFormat(',').withQuote('"').withHeader();

Expected result: all headers and values without quotes
Actual result: Exception in thread "main" java.io.IOException: (line 1) 
invalid char between encapsulated token and delimiter
at org.apache.commons.csv.Lexer.parseEncapsulatedToken(Lexer.java:275)
at org.apache.commons.csv.Lexer.nextToken(Lexer.java:152)
at org.apache.commons.csv.CSVParser.nextRecord(CSVParser.java:498)
at org.apache.commons.csv.CSVParser.initializeHeader(CSVParser.java:386)
at org.apache.commons.csv.CSVParser.<init>(CSVParser.java:283)
at org.apache.commons.csv.CSVParser.<init>(CSVParser.java:251)
at Runner.main(Runner.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

Thanks ahead for any answers.

Kulikov Andrey

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