How can I read a local file with Papa Parse? I have a file locally called challanges.csv
, but after many tried I can't parse it with Papa Parse.
var data;
Papa.parse('challanges.csv', {
header: true,
dynamicTyping: true,
complete: function(results) {
console.log(results);
data = results.data;
}
});
As far as I know, I'm having problems with opening the csv file as File. How can I do it with javascript?
You need to add one more line in your config:
download: true,
.Update: with this answer you dont need a FILE OBject. You can pass the filename and papa parse will "download" it.
The
File
API suggested by papaparse's docs is meant for browser used. Assuming that you are running this on node at server side, what works for me is leveraging the readable stream:There may be an easier interface, but so far this works quite well and offer the option of streaming for processing large files.