Forewarning, I am new to js and I crafted the code below was taken from Retrieve parsed data from CSV in Javascript object (using Papa Parse)
my goal = parse a csv file into an array, and use that array in a few other operations. I can see that the file is getting parsed properly via the "console.log("Row:", row.data);", but I cannot figure out how to get that entire array/dataset into a separate variable, much less into the "doSAtuff" function.
function parseData(url, callBack) {
Papa.parse(url, {
download: true,
header: true,
dynamicTyping: true,
comments: "*=",
step: function(row) {
console.log("Row:", row.data);
},
complete: function(results) {
callBack(results.data);
}
});
}
function doStuff(data) {
//Data should be usable here, but is emtp
console.log("doStuff - console log '" + data + "' ?");
}
parseData(inputFile, doStuff);
I think I want to do something like...
var csvArray = [];
csvArray = Papa.parse(url, {
download: true,
header: true,
dynamicTyping: true,
comments: "*
...
<some other stuff with csvArray>
but i'm a bit wrapped around the axle at the moment.