Created
August 14, 2015 04:21
-
-
Save nidate/5d917249f27246e41558 to your computer and use it in GitHub Desktop.
node.js の csv-parseで標準入力からcsvをパースする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
through2にobjectModeのオプションは必須。