Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onFileLoad receives an array of Papaparse results #105

Open
kenlim opened this issue Nov 12, 2021 · 1 comment
Open

onFileLoad receives an array of Papaparse results #105

kenlim opened this issue Nov 12, 2021 · 1 comment

Comments

@kenlim
Copy link

kenlim commented Nov 12, 2021

Hello,

When parsing a simple file with the header option set to true, the onFileLoad callback receives a result that looks like an array of Papaparse result objects:

[ 
{ data : {header: "val", header2: "val2"}, 
  errors :[], 
  meta : { ...data}
}, 
{ data : {header: "val3", header2: "val4"}, 
  errors :[], 
  meta : { ...data}
}, 
{ data : {header: "val5", header2: "val6"}, 
  errors :[], 
  meta : { ...data}
}, 
]

When the same string is called with Papaparse directly (in a unittest), it comes back as a Result object with an array of rows in the Data field:

{
data: [ 
  {header: "val", header2: "val2"}, 
  {header: "val3", header2: "val4"},
  {header: "val5", header2: "val6"}
],
errors: [],
meta: { ...data}
}

Is this intended behaviour? Or am I missing something?

I have an example of the problem here: https://codesandbox.io/s/peaceful-forest-tj6br?file=/src/CsvReader.js

@kenlim kenlim changed the title Parse result does not match base Papaparse result interface onFileLoad receives an array of Papaparse results Nov 13, 2021
@Bunlong
Copy link
Owner

Bunlong commented Nov 18, 2021

@kenlim

Yes, this is intended behaviour and I consider to follow the original one in version react-papaparse 4.0. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants