java.io.IOException: Un-terminated quoted field at end of CSV line
I have a CSV file(written in german language) and I m parsing it in my code.
CSVParser newLineParser = new CSVParser('\n');
try {
S开发者_运维知识库tring[] points = newLineParser.parseLine(csv);
CSVParser commaParser = new CSVParser();
int pointsLength = points.length;
for (int i = 1; i < pointsLength; i++) {
String[] pointComponents = commaParser.parseLine(points[i]);
}
}
catch (Exception e) {
Log.e("Exception", e.getMessage());
}
I am getting error in the parseLine method as:
java.io.IOException: Un-terminated quoted field at end of CSV line
what may be the reason for this error?
What I get from this is that in your CSV file a quote is opened but isn't closed.
malformed csv file
do some printouts in your loop, to see what happens before the program blows up.
If you are using OpenCSV API then this could be the problem:
Issue: One or more value in the csv file have multiple lines.
Fix: Use commaParser.parseLineMulti(points[i]) instead.
Source: Http://opencsv.sourceforge.net/apidocs/com/opencsv/CSVParser.html#parseLineMulti(java.lang.String)
精彩评论