Print CSV not working

I am trying to load a CSV file and print the contents. The file loads and I get the filename, but the rows and columns are not passed.

Here is my code:

"use strict";

let i, k, trows, tcols;
let table, loadButton;

function setup() {
  createCanvas(800, 800);
  background(200);
  loadButton = createFileInput(gotFile);
  loadButton.position(20, 20);

}

function gotFile(f) {

  print(`File "${f.name}" of type "${f.type}" was chosen.`);

  table = loadTable(f.data, "csv");
  trows = table.getRowCount();
  tcols = table.getColumnCount();

  print(trows + " rows/lines in table ");
  print(tcols + " cols in table");

  for (i = 0; i < tcols; i++) {
    print("col: " + i + " " + table.getColumnTitle(i));
  }

  for (k = 0; k < trows; k++) {
    for (i = 0; i < tcols; i++) {
      print("row: " + k + " col: " + i + " string: " + table.getString(k, i));
    }
  }
}

the output of the console:

File "iris.csv" of type "" was chosen. 
SEP IS , 
0 rows/lines in table  
0 cols in table 

What am I doing wrong?
Thanks in advance!

can you post the link where you run it?

Or the first 10 lines of the csv please?

Thanks Chrisir, got it working now.
Seems that the CSV format was not correct.

1 Like