Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Streaming and results

Tags:

papaparse

I'm just getting started with PapaParse, so sorry if this is a silly question.

If I parse a file, I get my nice results object, I can look at the headers, and all that:

Papa.parse(file, {
header: true,
dynamicTyping: true,    
complete: function(results) {
console.log("done");
data = results;
//headers = split(data[0]);
headers = results.meta['fields'];

However, if I add in a step callback, the results object in complete step is not defined. What am I actually supposed to do in the step callback? Their examples just dump the output of each row to the console.

Papa.parse(file, {
header: true,
dynamicTyping: true,
step: function(row) {
//console.log(row.data);
data.push(row.data);
},
complete: function(results) {
console.log("done");
data = results;
//headers = split(data[0]);
headers = results.meta['fields'];
like image 613
Andrew Avatar asked Nov 26 '25 22:11

Andrew


1 Answers

In papa parse, usually step i.e, streaming is normally used when you process a large file. So you will process the data as parser is reading them. And when streaming, parse results are not available in the complete callback.

To know more about streaming in papa parse check out this. Also, see more about the step function and complete callback in the config explanation section of the documentation.

Hope this Helps

like image 133
arifin4web Avatar answered Nov 28 '25 17:11

arifin4web



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!