Answers for "parse csv javascript"

0

parse csv javascript

//Suppose you have a CSV file data.csv which contains the data:

//NAME,AGE
//Daffy Duck,24
//Bugs Bunny,22

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(results));

 // [{ NAME: 'Daffy Duck', AGE: '24' },
//   { NAME: 'Bugs Bunny', AGE: '22' } ] 
Posted by: Guest on June-17-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language