Last active
July 29, 2016 19:54
-
-
Save SamSamskies/060d842315e1b2012671584e496184de to your computer and use it in GitHub Desktop.
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 fs = require('fs'); | |
var Converter = require('csvtojson').Converter; | |
var converter = new Converter({}); | |
var filename = 'FILENAME_WITHOUT_EXTENSION'; | |
converter.transform = function(json) { | |
// transformation for each row | |
}; | |
converter.on('end_parsed', function (jsonArray) { | |
const outputFilename = 'output.json'; | |
fs.writeFile(outputFilename, JSON.strigify(jsonArray), () => { | |
console.log(outputFilename, 'done'); | |
}); | |
}); | |
fs.createReadStream(`${filename}.csv`).pipe(converter); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment