[
https://issues.apache.org/jira/browse/CSV-265?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tyler King updated CSV-265:
---------------------------
Description:
The CSVRecord#getCharacterPosition method returns an incorrect value after the
CSVParser has encountered a comment in the CSV file.
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}
was:
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}
> 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
> Priority: Major
>
> The CSVRecord#getCharacterPosition method returns an incorrect value after
> the CSVParser has encountered a comment in the CSV file.
> 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)