Skip to content

not parsing wrapped delimiter in first column #153

@pustovitDmytro

Description

@pustovitDmytro

Background Information

  • Module Version: 3.7.3
  • Node/Browser Version: node v8.11.1

The issue I'm reporting is with:

  • json2csv
  • csv2json

I have...

  • searched to see if an issue has already been reported.
  • verified that my JSON/CSV data is valid (using something like http://jsonlint.com or https://csvlint.io/).
  • tried upgrading to the latest version of json-2-csv (since the issue may already be fixed).

Expected Behavior

a comma (delimiter) can be placed in first column.
[ { 'column 1': 'A,B', 'column 2': 'C,D', 'column 3': 'E,F' } ]

Actual Behavior

[ { 'column 1': '"A', 'column 2': 'B"', 'column 3': 'C,D' } ]

Data Sample

CSV:

column 1,column 2,column 3
"A,B","C,D","E,F"

(crlf line breaks used)

Code Example

import { csv2jsonAsync } from 'json-2-csv';

const headers = [ 'column 1', 'column 2', 'column 3' ];
const csvopts = {
        delimiter : {
            field : ',',
            eol   : '\r\n'
        },
        keys : headers
    };

const fileData = await fs.readFile(filePath, 'UTF-8');
const data =  await csv2jsonAsync(fileData, csvopts);

In second and third columns delimiter is parsed correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions