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

String delimiter (||) is not working as expected.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.10.0
    • None
    • None

    Description

      Steps to reproduce  : 
      1. Parse CSV file with || as delimiter and having empty columns
      2. Print the CSVRecord resulting from CSVParser

       
      //Expected : a,b,c,d,,f,g
      // Actual : a,b|c,d,|f,g

      public static void main(String[] args) throws Exception{
      String row = "a||b||c||d||||f||g";
      StringBuilder stringBuilder = new StringBuilder();
      try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL);
      CSVParser csvParser = CSVParser.parse(new StringInputStream(row), StandardCharsets.UTF_8, CSVFormat.Builder.create().setDelimiter("||").build())) {
      for (CSVRecord csvRecord : csvParser) {
      for (int i = 0; i < csvRecord.size(); i++)

      { csvPrinter.print(csvRecord.get(i)); }

      System.out.println(stringBuilder.toString());
      //Expected : a,b,c,d,,f,g
      // Actual : a,b|c,d,|f,g
      }
      }
      }

      With the snippet provided above, actual value is not same as expected value

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              san4you88 Santhsoh
              Votes:
              0 Vote for this issue
              Watchers:
              4 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 - 40m
                  40m