Im using csv-parser npm package and doing a sample csv parse. My only confusion is accessing the parsed array after running these functions. I understand im pushing the data in .on('data') , then doing a console.log(results); statement in .on('end'); to show what's being stored. Why do I get undefined when i try to access results after running those functions. Doesn't results get the information stored?
const csv = require('csv-parser');
const fs = require('fs');
const results = [];
fs.createReadStream('demo.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
()fromcsv()callType Error: dest.on is not a function.on('end', () => { console.log(results);});, but if I put aconsole.log()after thecreateReadStream, results is undefined, does that make sense?()and gotdest.on is not a function, that means thecsv()function is not returning an object with anon()method. This most likely meanscsv()is not returning a Stream.