问题
I am trying to first read the CSV file, but I am getting an error saying:
TypeError: fs.createReadStream is not a function.
Am I doing something wrong? Here is my code:
fs.createReadStream('accounts.csv')
.pipe(csv())
.on('data', function (data) {
console.log(data);
})
.on('end', function () {
console.log('Read finished');
});
回答1:
I realized that i did not have the file inside my project, which is the reason it was not reading it, also, i changed my code to this.
const csv = require('csv-parser');
const fs = require('fs');
const fast = require('fast-csv');
fs.createReadStream('accounts.csv')
.pipe(csv())
.on('data', (row) => {
console.log(row);
})
.on('end', () => {
console.log('CSV file successfully processed');
来源:https://stackoverflow.com/questions/55031113/using-fast-csv-not-reading-csv-file