Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created April 11, 2019 23:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/9f18bfd6355e237c9c22daab8973ed89 to your computer and use it in GitHub Desktop.
Save isaacs/9f18bfd6355e237c9c22daab8973ed89 to your computer and use it in GitHub Desktop.
const fs = require('fs')
const parse = require('csv-parse')
const parserStream = parse({
columns: true,
skip_empty_lines: true
})
fs.createReadStream('file.csv')
.pipe(parserStream)
.on('data', record => console.log('record', record))
key_1 key_2
value 1 value 2
value again another key2 value
@isaacs
Copy link
Author

isaacs commented Apr 11, 2019

$ node csv-example-for-laurie.js
record { key_1: 'value 1', key_2: 'value 2' }
record { key_1: 'value again', key_2: 'another key2 value' }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment