[ https://issues.apache.org/jira/browse/CSV-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14275877#comment-14275877 ]
Steven Peterson commented on CSV-147: ------------------------------------- Hi Benedict: Thanks for taking the time to look at this. I am referring to the record buffer that is a private property of the CSVParser of type List<String> (see declaration below). When I look at the code, it appears this List<String> is reset at the beginning of every new CSV record, then as tokens are parsed, they are added to this buffer. If an exception is thrown while parsing the fourth token in a record, the first three tokens should be present in this List. So I should not have called it a record, it is really a holding place/buffer of what has been parsed so far in that record before hitting the exception. It is this buffer that would be useful. Of course the complete line from the CSV file that caused the problem would be the most useful, but having access to this partial buffer seemed to be a quick-&-dirty way to get some information on the problem record. private final List<String> record = new ArrayList<String>(); > Better error handling in CSV, see included code > ----------------------------------------------- > > Key: CSV-147 > URL: https://issues.apache.org/jira/browse/CSV-147 > Project: Commons CSV > Issue Type: Improvement > Components: Parser > Affects Versions: 1.1 > Reporter: Steven Peterson > Labels: easyfix > Fix For: Discussion > > Original Estimate: 0.25h > Remaining Estimate: 0.25h > > When parsing long files, and there is problem with parsing the data, it would > be very useful to know the exact data that is bad when an exception is > thrown. As CSVParser maintains a portion of the current record that was read > when an exception is thrown (in the 'record' property), can we make this > information public through something like this: > {code:java} > public String[] getLastRecordData() { > return this.record.toArray(new String[this.record.size()]); > } > {code} > With a method like this, it would be easy to pull in part of the data that > was in the faulty record after an exception was thrown, aiding in cleaning up > the data. -- This message was sent by Atlassian JIRA (v6.3.4#6332)