react-papaparse icon indicating copy to clipboard operation
react-papaparse copied to clipboard

onFileLoad receives an array of Papaparse results

Open kenlim opened this issue 4 years ago • 1 comments

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 avatar Nov 12 '21 22:11 kenlim

@kenlim

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

Bunlong avatar Nov 18 '21 13:11 Bunlong