I am trying to read a csv file using node js. Her is my code
fs.readFile(config.csvUploadPath, function read(err, data) { if (err) { throw err;
I used a stream, fs, and csv-parse like in this answer:
fs
csv-parse
const parse = require('csv-parse') const fs = require('fs') const data = [] fs.createReadStream(filename) .pipe(parse({ delimiter: ',' })) .on('data', (r) => { console.log(r); data.push(r); }) .on('end', () => { console.log(data); })