Home > Mobile >  CSV to HTML - How to Stop indexing using papa parse
CSV to HTML - How to Stop indexing using papa parse

Time:03-06

Just due to low rep(sorry) had to extend this thread: CSV to html table

var csv_array = ["dashboard.csv"];
    $(function() {
        $(csv_array).each(function(){
            Papa.parse(this.toString(), {
                download: true,
                complete: function(results) {
                    console.log("Remote file parsed!", results.data);
                    $.each(results.data, function(i, el) {
                        var row = $("<tr/>");
                        row.append($("<td/>").text(i));
                        $.each(el, function(j, cell) {
                            if (cell !== "")
                                row.append($("<td/>").text(cell));
                        });
                        $("#results tbody").append(row);
                    });
                }
            });

        })

    }); 

This works well, however, it's generating an index on the left side, numbering the columns. How does one remove that index? Thanks!

CodePudding user response:

Figured this out(With someone's assistance offsite):

Removed the 'i' from row.append($("").text(i));

If this isnt the answer, please continue to comment a better way. Thanks!

var csv_array = ["dashboard.csv"];
    $(function() {
        $(csv_array).each(function(){
            Papa.parse(this.toString(), {
                download: true,
                complete: function(results) {
                    console.log("Remote file parsed!", results.data);
                    $.each(results.data, function(i, el) {
                        var row = $("<tr/>");
                        row.append($("<td/>").text());
                        $.each(el, function(j, cell) {
                            if (cell !== "")
                                row.append($("<td/>").text(cell));
                        });
                        $("#results tbody").append(row);
                    });
                }
            });

        })

    }); 
  • Related