harrisonhunter / papa-parse-meteor

Papa Parse packaged for Meteor
MIT License
19 stars 6 forks source link

Always getting results undefined #4

Open isAlmogK opened 9 years ago

isAlmogK commented 9 years ago

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);
            }
        });
    });
wuzhuzhu commented 9 years ago

got the same problem

samylaumonier commented 8 years ago

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);
    }
});
harrisonhunter commented 8 years ago

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

harrisonhunter commented 5 years ago

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