0

I'm combining 2 csv spreadsheets into 1. Fist sheet/half has a certain format (let's say- round number, decimals, percentage, round number), and 2nd part/half has a different format (let's say decimals, currency, round number, round number). I insert contains of 2nd sheet right under the first one, make sure there is equal amount of columns and parse it. First half gets all the numbers right. When it gets to 2nd half, 80% of numbers are different (usually, smaller than the actual ones in the spreadsheet).

Not sure if it has something to do with formating of it or something else.

JS is pretty standard

 function arrayToTable(tableData) {
    var table = $('<table></table>');
    $(tableData).each(function (i, rowData) {
        var row = $('<tr></tr>');
        $(rowData).each(function (j, cellData) {
            row.append($('<td>'+cellData+'</td>'));
        });
        table.append(row);
    });
    return table;
}

$.ajax({
    type: "GET",
    url: "data/late2.csv",
    success: function (data) {
        $('body .tableclass').append(arrayToTable(Papa.parse(data).data));
     }
   });
  • `$(tableData)` will have unexpected behaviour. It's only meant for selectors. Perhaps you meant `$.each(tableData, ...)` – 4castle Jan 06 '17 at 20:00
  • I'm as noob as they come, and was using code in the example. Do I use above code as it is, or do i put something there instead of "..."? – Shalambalam Jan 06 '17 at 20:26
  • Sorry, yes the `...` was meant as an "etc". Here's the [documentation](http://api.jquery.com/jquery.each/) for what you need. The code will be `$.each(tableData, function(i, rowData) { /* statements here */ });` – 4castle Jan 06 '17 at 22:30

0 Answers0