Skip to content

Instantly share code, notes, and snippets.

@nidate
Created August 14, 2015 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nidate/5d917249f27246e41558 to your computer and use it in GitHub Desktop.
Save nidate/5d917249f27246e41558 to your computer and use it in GitHub Desktop.
node.js の csv-parseで標準入力からcsvをパースする
# http://csv.adaltas.com/parse/
csvParse = require 'csv-parse'
through2 = require 'through2'
stream = process.stdin
csv = csvParse columns: true
stream
.pipe(csv)
.pipe through2 objectMode: true, (chunk, enc, next)->
console.log JSON.stringify chunk, null, 2
next()
.on 'error', (err)->
console.error err.stack or err
@nidate
Copy link
Author

nidate commented Aug 14, 2015

through2にobjectModeのオプションは必須。

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