D. Singh D. Singh - 3 months ago 28
Node.js Question

Node js does not parse the csv file using fast-csv library

I'm using the fast-csv node library to parse a csv-file named myFile.csv. The code looks like this:

var csv = require("fast-csv");
var fs = require("fs");
var stream = fs.createReadStream('myFile.csv');
csv
.fromStream(stream, {headers : true})
.on("data", function(data){
console.log("Start of parsing...");
console.log(data);
})
.on("end", function(data){
console.log(data);
console.log("End of parsing");
})


When I run it, I see the following two lines in node console:

1
End of parsing


It doesn't print "Start of parsing..." or any data from the csv file. What could be the reason for that? Thanks in advance!

Answer

Just reinstall fast-csv module by using the following command:

npm install fast-csv --save