I'm trying to converte a csv local file to json and send it to an API.
But I have a problem with each function that I've found around.
I pick the csv file from event target like this
const csvAsJson = this.csvJSON(event.target.files[0])
Then in csvJSON
function I have this:
csvJSON = csv => {
console.log(csv)
var lines=csv.split("\n");
// more code...
But I get an error at the split
"csv.split is not a function".
In the console.log(csv)
I got this:
File {name: "my file name.csv", lastModified: 1578504279032, lastModifiedDate: Wed Jan 08 2020 14:24:39 GMT-0300 (hora de verano de Chile), webkitRelativePath: "", size: 8809, …}
name: "my file name.csv"
lastModified: 1578504279032
lastModifiedDate: Wed Jan 08 2020 14:24:39 GMT-0300 (hora de verano de Chile) {}
webkitRelativePath: ""
size: 8809
type: "application/vnd.ms-excel"
__proto__: File
How should I use the split in a csv that is a file? I don't get it.