adaltas / node-csv

Full featured CSV parser with simple api and tested against large datasets.

Home Page:https://csv.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

First value of the first row has a leading space.

tengotengo opened this issue · comments

const { parse } = require('csv-parse');
const fs = require('fs');

const parser = parse(fs.readFileSync('./data2.csv').toString(), {
}, function (err, records) {
console.log(111, 're111cords', records);
});

data2.csv:

102,10790 WILSHIRE BLVD,Los Angelse,CA,90024
104,1005 N 4TH STREET,Montebello,CA,90640

output:

111 re111cords [
[ ' 102', '10790 WILSHIRE BLVD', 'Los Angelse', 'CA', '90024' ],
[ '104', '1005 N 4TH STREET', 'Montebello', 'CA', '90640' ]
]

When copy/pasting your code above into vscode, I can see an invisible character in your sample:
image

It might be becase you are sourcing an utf-8 file with a leading BOM inside. Try adding the {bom: true} option.