You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2021/07/16 14:44:00 UTC
[jira] [Commented] (CSV-265) CSV comments break
CSVRecord#getCharacterPosition
[ https://issues.apache.org/jira/browse/CSV-265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17382112#comment-17382112 ]
Gary D. Gregory commented on CSV-265:
-------------------------------------
Please include the result of running the code in the description.
> 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
> Time Spent: 2h 10m
> Remaining Estimate: 0h
>
> The CSVRecord#getCharacterPosition method returns an incorrect value after the CSVParser has encountered a comment in the CSV file.
> Example:
>
> {code:java}
> String csv = "# Comment\n"
> + "Headers,Header2\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)