Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several comma's prevent csv() identify fields in text #479

Open
svakulenko opened this issue Jul 12, 2023 · 0 comments
Open

Several comma's prevent csv() identify fields in text #479

svakulenko opened this issue Jul 12, 2023 · 0 comments

Comments

@svakulenko
Copy link

Hello

Issue
I notice that several comma's in text avoid parser to split text correctly between fields.
Reproduced with version 2.0.0 and older versions of library.

Bootcode:

const options = {
            noheader: true,
            delimiter: [",",";"]        
        }
let responseDataModified = fs.readFileSync("myfile_working_example.csv", 'utf8')

csv(options)
        .fromString(responseDataModified)
        .subscribe(function(json){
            let stringed = JSON.stringify(json)
            console.log(JSON.stringify(json)
            }
        })

myfile_working_example.csv

"MY_TEXT_KEY";"Content of My Text.";"C'est le content, le content du text."

myfile_example_with_bug.csv

"MY_TEXT_KEY";"Content of My Text.";"C'est le content, le, content du text."

Description of issue

Launch parser with myfile_working_example.csv file will generate output with 3 fields and its what we expect.

output using myfile_working_example.csv:

{"field1":"MY_TEXT_KEY","field2":"Content of My Text.","field3":"C'est le content, le content du text."}

However, launch parser with myfile_example_with_bug.csv file will generate output where fields are not separate and merged in single field which is error. The reason is added comma in le, content part of text

output using myfile_example_with_bug.csv:

{"field1":"MY_TEXT_KEY\";\"Content of My Text.\";\"C'est le content, le, content du text."}

to note: if delimiter will not contain comma, it will split correctly the text with myfile_example_with_bug.csv. However, as API of delimiter its array of items, it looks like border condition that provoke bug.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant