You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Panxianhao (Jira)" <ji...@apache.org> on 2022/07/26 03:34:00 UTC

[jira] [Created] (CSV-299) get unexpected results when setting the delimiter to ‘||’

Panxianhao created CSV-299:
------------------------------

             Summary: get unexpected results when setting the delimiter to ‘||’
                 Key: CSV-299
                 URL: https://issues.apache.org/jira/browse/CSV-299
             Project: Commons CSV
          Issue Type: Bug
          Components: Parser
    Affects Versions: 1.9.0
            Reporter: Panxianhao
         Attachments: image-2022-07-26-11-24-43-484.png, image-2022-07-26-11-27-23-629.png, image-2022-07-26-11-29-15-281.png, image-2022-07-26-11-29-54-455.png, image-2022-07-26-11-31-57-920.png, image-2022-07-26-11-32-25-643.png

a simple but strange problem

the csv file is like 

!image-2022-07-26-11-24-43-484.png|width=497,height=51!

and the parse code is 

 
{code:java}
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);
} {code}
the output should be 

YW-20210402-Z3N9X

0

13500900001|*|\{"name":"Mr.Chen13500900001"}
----
but I get the wrong result

!image-2022-07-26-11-27-23-629.png|width=557,height=36!
----
if I add a space after the 0 like this 

!image-2022-07-26-11-29-15-281.png|width=546,height=35!

I can get the result I want

!image-2022-07-26-11-29-54-455.png|width=552,height=31!
----
if I change the number >=10  without a space it works just fine

!image-2022-07-26-11-31-57-920.png|width=519,height=30!

!image-2022-07-26-11-32-25-643.png|width=528,height=26!
----
Hope I can get reply from you, thx!

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)