Created
March 17, 2015 21:01
-
-
Save gabhi/6198f61fbf320f12b4e2 to your computer and use it in GitHub Desktop.
csv to json node js
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 Converter=require("csvtojson").core.Converter; | |
var fs=require("fs"); | |
var csvFileName="./test.csv"; | |
var fileStream=fs.createReadStream(csvFileName); | |
//new converter instance | |
var csvConverter=new Converter({constructResult:true}); | |
//end_parsed will be emitted once parsing finished | |
csvConverter.on("end_parsed",function(jsonObj){ | |
console.log(jsonObj); //here is your result json object | |
}); | |
//read from file | |
fileStream.pipe(csvConverter); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment