papa-parse-meteor
papa-parse-meteor copied to clipboard
Always getting results undefined
I'm trying to parse a CSV to JSON but I'm always getting results undefined
This is what I have
<input type="file" id="csv-file" name="files"/>
$('input').change(function(e) {
$('input[type=file]').parse({
config: {
// base config to use for each file
},
before: function(file, inputElem)
{
console.log(file);
// executed before parsing each file begins;
// what you return here controls the flow
},
error: function(err, file, inputElem, reason)
{
console.log(err);
// executed if an error occurs while loading the file,
// or if before callback aborted for some reason
},
complete: function(results, file) {
console.log("Parsing complete:", results, file);
}
});
});
got the same problem
I had the same problem, I think that it's because the parser version used in the package is v4.0.7 while the documentation is for v4.1.
You should do this, it's how I got it to work:
var file = $('input[type=file]')[0].files[0];
Papa.parse(file, {
// ...
complete: function(results, file) {
console.log("Parsing complete:", results, file);
}
});
Updated to version 4.1, let me know if that fixes things
Added this note to the ReadME but wanted to post here in case anyone is subscribed to this thread:
Note: This package is no longer necessary: Note: If you are using a recent version of Meteor or imports, you no longer need this package. You can install the papaparse npm package directly and import it. In the root of your meteor project run meteor npm install --save papaparse. Then, you can import with import Papa from 'papaparse'; or import * as Papa from 'papaparse';
This problem is likely solved by switching to the npm version of the package OR is a problem in the npm version of the package and is thus out of scope for this repo