parsing - Retrieve parsed data from CSV in Javascript object (using Papa Parse) -
I am ashamed of this question because it seems that it should be so obvious, but I am very weak dealing with Async problems But, and I'm confused on how to proceed.
I am using Papa Pars () to parse a remote CSV. I want to hide the result of parse in an object for later use. Here's my code:
var dataset = {}; dad. Parse ("http: //path/to/some.csv", {download: true, dynamic typing: true, complete: function (result) {dataset = results.data;}}); Console.log (dataset); This, of course, resulted in being logged in the empty object in the console. Any effort to use a dataset does not work, of course, the dataset object is not actually received by the time the code is executed. Can anyone help me in a reseller or explain how I work with it?
Do the dataset variables need to be used outside of the function? The easiest way to ensure that the dataset population is in the 'complete' function is to manipulate datasets right after that, well, the population
is an optional callback similar to adding:
function doStuff (data) {// data is useful here console.log (data); } Function parseData (url, callback) {papa. Parse (url, {download: correct, dynamic typing: true, complete: work (results) {callBack (results.data);}}); } ParseData ("test / sample.csv", doStuff);
Comments
Post a Comment