Created
March 1, 2015 23:54
-
-
Save max-mapper/a9a572e7fa711055c630 to your computer and use it in GitHub Desktop.
csv parsing + transform pipeline
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
var csv = require('csv-parser') | |
var through = require('through2') | |
var ndjson = require('ndjson') | |
var fs = require('fs') | |
fs.createReadStream(process.argv[2]) | |
.pipe(csv()) | |
.pipe(through.obj(map)) | |
.pipe(ndjson.serialize()) | |
.pipe(process.stdout) | |
function map(obj, enc, next) { | |
obj.foo = "bar" | |
this.push(obj) | |
next() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
could use https://www.npmjs.com/package/csv-write-stream for generating a csv at the end