node-csv icon indicating copy to clipboard operation
node-csv copied to clipboard

First value of the first row has a leading space.

Open tengotengo opened this issue 1 year ago • 1 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' ] ]

tengotengo avatar May 23 '24 23:05 tengotengo

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.

wdavidw avatar May 24 '24 05:05 wdavidw

Issue was explained on our side, closing.

wdavidw avatar Dec 13 '24 08:12 wdavidw