1//Suppose you have a CSV file data.csv which contains the data:
2
3//NAME,AGE
4//Daffy Duck,24
5//Bugs Bunny,22
6
7const csv = require('csv-parser')
8const fs = require('fs')
9const results = [];
10
11fs.createReadStream('data.csv')
12 .pipe(csv())
13 .on('data', (data) => results.push(data))
14 .on('end', () => console.log(results));
15
16 // [{ NAME: 'Daffy Duck', AGE: '24' },
17// { NAME: 'Bugs Bunny', AGE: '22' } ]