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

CSVParser does not properly handle multiline CSV entries #5

Open
danypype opened this issue Jul 31, 2018 · 0 comments
Open

CSVParser does not properly handle multiline CSV entries #5

danypype opened this issue Jul 31, 2018 · 0 comments
Labels

Comments

@danypype
Copy link
Contributor

CSV standard RFC 4180, page 2 states:

  1. 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' }
@danypype danypype added the bug label Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant