Synchronous processing of a csv file using fast-csv
You can pause the parser, wait for saveData
to complete, and subsequently resume the parser:
var parser = csv.fromStream(stream, {headers : true}).on("data", function(data) { console.log('here'); parser.pause(); module.exports.saveData(data, function(err) { // TODO: handle error parser.resume(); });}).on("end", function(){ console.log('end of saving file');});module.exports.saveData = function(data, callback) { console.log('inside saving') // Simulate an asynchronous operation: process.setImmediate(callback);}