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

get unexpected results when setting the delimiter to ‘||’

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.9.0
    • 1.10.0
    • Parser
    • None

    Description

      a simple but strange problem

      the csv file is like 

      and the parse code is 

       

      File csv = new File("src/main/resources/test.csv");
      CSVFormat format = CSVFormat.Builder.create()
              .setDelimiter("||")
              .setRecordSeparator("\n")
              .build();
      Iterable<CSVRecord> records = format.parse(new FileReader(csv));
      for (CSVRecord record : records) {
          System.out.println(record);
      } 

      the output should be 

      YW-20210402-Z3N9X

      0

      13500900001|*|{"name":"Mr.Chen13500900001"}


      but I get the wrong result


      if I add a space after the 0 like this 

      I can get the result I want


      if I change the number >=10  without a space it works just fine


      Hope I can get reply from you, thx!

       

      Attachments

        1. image-2022-07-26-11-24-43-484.png
          16 kB
          Panxianhao
        2. image-2022-07-26-11-27-23-629.png
          16 kB
          Panxianhao
        3. image-2022-07-26-11-29-15-281.png
          14 kB
          Panxianhao
        4. image-2022-07-26-11-29-54-455.png
          16 kB
          Panxianhao
        5. image-2022-07-26-11-31-57-920.png
          14 kB
          Panxianhao
        6. image-2022-07-26-11-32-25-643.png
          16 kB
          Panxianhao

        Activity

          People

            Unassigned Unassigned
            Panxianhao Panxianhao
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: