0

I have simple Node js script that read a csv file and push data in array.

const csv = require('csv-parser')
const fs = require('fs')
const results = [];

fs.createReadStream('data.csv')
  .pipe(csv())
  .on('data', (data) => results.push(data))
  .on('end', () => {
    console.log("Done");
  });

  console.log(results[10])

I would like node first read whole of csv and next print array. Any solution?

0 Answers0