Skip to content

Instantly share code, notes, and snippets.

@max-mapper
Created March 1, 2015 23:54
Show Gist options
  • Save max-mapper/a9a572e7fa711055c630 to your computer and use it in GitHub Desktop.
Save max-mapper/a9a572e7fa711055c630 to your computer and use it in GitHub Desktop.
csv parsing + transform pipeline
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()
}
@max-mapper
Copy link
Author

could use https://www.npmjs.com/package/csv-write-stream for generating a csv at the end

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