Uploaded image for project: 'Commons CSV'
  1. Commons CSV
  2. CSV-265

CSV comments break CSVRecord#getCharacterPosition

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.9.0
    • Component/s: Parser
    • Labels:
      None

      Description

      The CSVRecord#getCharacterPosition method returns an incorrect value after the CSVParser has encountered a comment in the CSV file.

      Example:

       

      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);

       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              tking Tyler King
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 3h
                3h