Get Data from CSV File in nodejs
Node comes with a readline module in it's core, allowing you to process a readable stream line by line.
var fs = require("fs"), readline = require("readline");var file = "something.csv";var rl = readline.createInterface({ input: fs.createReadStream(file), output: null, terminal: false})rl.on("line", function(line) { console.log("Got line: " + line);});rl.on("close", function() { console.log("All data processed.");});
I think the module 'split' by dominic tarr will suffice.It breaks up the stream line by line.https://npmjs.org/package/split
fs.createReadStream(file) .pipe(split()) .on('data', function (line) { //each chunk now is a seperate line! })