papa-parse-meteor icon indicating copy to clipboard operation
papa-parse-meteor copied to clipboard

Always getting results undefined

Open isAlmogK opened this issue 10 years ago • 4 comments

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);
            }
        });
    });

isAlmogK avatar Feb 10 '15 11:02 isAlmogK

got the same problem

wuzhuzhu avatar Aug 04 '15 16:08 wuzhuzhu

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);
    }
});

samylaumonier avatar Nov 04 '15 16:11 samylaumonier

Updated to version 4.1, let me know if that fixes things

harrisonhunter avatar Nov 04 '15 22:11 harrisonhunter

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

harrisonhunter avatar Dec 20 '18 03:12 harrisonhunter