I have been trying to get papaparse
running on nodejs
for a very long time now and I keep failing. I want to try to load my local CSV and then give this papaparse
? How to do that? My code does not work.
import papa from "papaparse";
import fs from "fs";
export const convertCSV = async (res: Response) => {
const file = await fs.createReadStream("../files/test.csv");
papa.parse(file, {
header: true,
complete: function (results, file) {
console.log("Complete", results.data.length, "records.");
},
});
};
results.data.length
is always 0
.
My CSV file is located in the files folder, which is located in the src folder:
src/files/test.csv