Drop CSV file to loadTable()

Hi @GoToLoop

I don’t see the “link below”

Do you mean you got something like this to work ?


let myTable;

function setup() {
  const c = createCanvas(710, 400);
  background(100);
  c.drop(gotFile);
}

function draw() {
  fill(255);
  noStroke();
  textSize(24);
  textAlign(CENTER);
  text('Drag the file onto the canvas.', width / 2, height / 2);
  noLoop();
}

function gotFile(file) {

  if (file.type === 'text') {

  myTable = loadTable(file.data, 'csv', 'header');

  text(myTable.getString(1,1), width / 2, height / 2 + 20);

  } else {
    console.log('Not a proper file!');
  }
}