I have a Node app in a directory together with a text file called sample.csv.
I'm trying to read the file line-by-line with the following code, but nothing gets read:
var readline = require('readline');
var fs = require('fs');
var lineReader = readline.createInterface({
input: fs.createReadStream('sample.csv')
});
lineReader.on('line', function (line) {
console.log(line); // Never happens
});
console.log('Completed.'); // Immediately skips to this
Any bright ideas? :) Thanks!