I would have expected that I got all the CSV data in the array, but for some reason I don't get anything.
Can someone explain why a
is empty at the end?
const fs = require('fs');
const { parse } = require('csv-parse');
let a = [];
fs.createReadStream('./example.csv')
.pipe(parse({ delimiter: ';', from_line: 2 }))
.on('data', function (row) {
a.push(row);
})
.on('end', function () {
console.log('finished');
})
.on('error', function (error) {
console.log(error.message);
});
console.log(a);