Answers for "csv to json javascript"

90

csv to json javascript

// Install
npm i csvtojson

// From CSV File to JSON Array
/** csv file
a,b,c
1,2,3
4,5,6
*/
const csvFilePath='<path to csv file>'
const csv=require('csvtojson')
csv()
.fromFile(csvFilePath)
.then((jsonObj)=>{
    console.log(jsonObj);
    /**
     * [
     * 	{a:"1", b:"2", c:"3"},
     * 	{a:"4", b:"5". c:"6"}
     * ]
     */ 
})
Posted by: Guest on June-15-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language