You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Tyler King (Jira)" <ji...@apache.org> on 2020/10/27 19:46:00 UTC
[jira] [Created] (CSV-265) CSV comments break
CSVRecord#getCharacterPosition
Tyler King created CSV-265:
------------------------------
Summary: CSV comments break CSVRecord#getCharacterPosition
Key: CSV-265
URL: https://issues.apache.org/jira/browse/CSV-265
Project: Commons CSV
Issue Type: Bug
Components: Parser
Affects Versions: 1.8
Reporter: Tyler King
The CSV#getCharacterPosition method returns an incorrect value after the CSVParser has encountered a comment in the CSV files.
Example:
{code:java}
String csv = "Header1,Header2\n"
+ "# Comment\n"
+ "Value1,Value2\n";
CSVFormat format = CSVFormat.EXCEL.withCommentMarker('#').withFirstRecordAsHeader();
CSVParser parser = new CSVParser(new StringReader(csv), format);
long expectedPosition = csv.indexOf("Value1");
long actualPosition = parser.iterator().next().getCharacterPosition();
assertEquals(expectedPosition, actualPosition);{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)