I am trying to convert a .csv file into a JSON object in Reactjs. For this, I add the file I need to convert into the project structure under a folder called Data. I then found this npm package https://www.npmjs.com/package/convert-csv-to-json and tried the following piece of code to convert file
import { getJsonFromCsv } from "convert-csv-to-json";
...
let json = getJsonFromCsv('./Data/finaldata.csv');
for (let i = 0; i < json.length; i++) {
console.log(json[i]);
}
But trying this is throwing an
"TypeError: fs.readFileSync is not a function"
So I would like to know if something is wrong with my code or Can someone suggest another method to convert CSV file to JSON