user3089079
user3089079

Reputation: 59

PapaParse not working (returns empty array)

I am trying to parse a variant of this file (instead of using tab as delimiter I am using a file that has comma as delimiter) https://github.com/materechm/Schizophrenia/blob/master/GWAS.txt

This is my code, but I am getting an empty array and no errors

        var csv = Papa.parse('GWAS.csv', {
        delimiter: ",",
        header: true,
        comments: false,
        complete: function(results) {
        console.log(results);
        }
        });

Upvotes: 2

Views: 5499

Answers (1)

Matt
Matt

Reputation: 23759

There is no data because you have header row enabled, so the first line of the input is the header row (look in the meta property for the list of fields found in the header row).

You've supplied only one line of input, literally the string "GWAS.csv", so there is no data.

If you meant to parse a file, you need to either pass in a File object from the DOM or specify download: true in the config for Papa Parse to interpret the input string as a URL from which to download the input file.

Upvotes: 2

Related Questions