I am trying to parse a simple csv file in javascript. I've seen some questions in Stackoverflow, but the solutions are having a input field in the html body. But I want to read the data from local disk directly in the javascript. I've googled and found some scripts like papaparse, jquery.csv. But couldn't find the logic to load the file into javascript. Below is the code that I tried with papaparse.js
var file = new File([""], "TweetSource.txt");
var ts = Papa.parse(file, {
header: false,
delimiter: ",",
dynamicTyping: true
complete: function(results) {
var data = results;
return data;
});
The code is not loading the text file. Also, I'm confused with the later steps (how to go through the ts
variable)
Please help me.
Thanks.