Skip to content

Instantly share code, notes, and snippets.

@gabhi
Created April 2, 2015 05:51
Show Gist options
  • Select an option

  • Save gabhi/f7d24f850ffa9c2770e5 to your computer and use it in GitHub Desktop.

Select an option

Save gabhi/f7d24f850ffa9c2770e5 to your computer and use it in GitHub Desktop.
CSV to JSON node js
var Converter=require("csvtojson").core.Converter;
var csvConverter=new Converter({constructResult:false, toArrayString:true}); // The constructResult parameter=false will turn off final result construction in memory for stream feature. toArrayString will stream out a normal JSON array object.
var readStream=require("fs").createReadStream("top-1m.csv");
var writeStream=require("fs").createWriteStream("outpuData.json");
readStream.pipe(csvConverter).pipe(writeStream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment