1

I am trying something like the following, but this doesn't work

const parser = parse(req.file, {
  headers: true
})
// Use the readable stream api
parser.on('data', function(csvrow) {
  console.log(csvrow);
})
user2763557
  • 449
  • 5
  • 18
  • [have a look](https://stackoverflow.com/questions/16831250/how-to-convert-csv-to-json-in-node-js) – Dohab Feb 27 '19 at 04:15
  • for anyone who comes to this in the future, if you scroll down in the link @Dohab provies, the answer is there. thanks dohab! – user2763557 Feb 27 '19 at 14:28

1 Answers1

0

This worked for me

parse(sampleFile, {columns: true}, function(err, data){
        console.log(JSON.stringify(data,null,2));
    });
user2763557
  • 449
  • 5
  • 18