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

CSV comments break CSVRecord#getCharacterPosition

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.8
    • 1.9.0
    • Parser
    • 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

            Unassigned Unassigned
            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