-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
CSV standard RFC 4180, page 2 states:
- Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes. For example:
"aaa","b CRLF bb","ccc" CRLF zzz,yyy,xxx
However, when we run this:
~/test_file.csv:
hotel_name,address,star_rating
"County Hall","Westminster Bridge Road
London",4
"St. Ermin's Hotel","2 Caxton Street London",5
~/csv_parser_test.js
const CSVParser = require('./csv-parser');
const parser = new CSVParser({
sourceFilePath: 'test_file.csv'
}, {
name: 'hotel_name',
address: 'address',
stars: 'star_rating',
});
parser.on('object', (hotel, next) => {
console.log(hotel);
process.nextTick(next);
});
parser.start();We get 3 objects back:
$ node csv_parser_test.js
{ name: '"County Hall"',
address: '"Westminster Bridge Road',
stars: undefined }
{ name: 'London"', address: '4', stars: undefined }
{ name: '"St. Ermin\'s Hotel"',
address: '"2 Caxton Street London"',
stars: '5' }
Reactions are currently unavailable