Skip to content

Instantly share code, notes, and snippets.

@adamanthil
Created August 13, 2014 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamanthil/f31eb8314ce2d05a131a to your computer and use it in GitHub Desktop.
Save adamanthil/f31eb8314ce2d05a131a to your computer and use it in GitHub Desktop.
The following javascript should stop triggering events before running through the entire sample csv file using the csvtojson module. See issue: https://github.com/Keyang/node-csvtojson/issues/28
var importIndex = 0;
var csvConverter = new Converter({ constructResult:false });
var fileStream = fs.createReadStream('large-csv-sample.csv');
csvConverter.on('record_parsed',function(rowObj, rowArray, rowIndex){
var rowId = rowArray[0];
var fileNum = rowArray[1];
importIndex++;
console.log(rowId, importIndex);
});
fileStream.pipe(csvConverter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment