A npm package that coverts your csv file to a json file
npm i @tush-tr/csv2json
const csv2json = require("@tush-tr/csv2json")
const fs = require('fs')
const csv2json = require("@tush-tr/csv2json")
const {parse} = require('csv-parse')
function readFile(path){
return new Promise((resolve,reject)=>{
fs.readFile(path, function (err, fileData) {
parse(fileData, {columns: false, trim: true}, async function(err, rows) {
if(err){
reject(err)
}
resolve(rows)
})
})
})
}
async function main(){
const csvData = await readFile("test.csv");
const jsonData = JSON.stringify(csv2json(csvData))
console.log(jsonData)
}
main()