Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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' } ] 
Source by www.npmjs.com #
 
PREVIOUS NEXT
Tagged: #parse #csv #javascript
ADD COMMENT
Topic
Name
7+7 =