Skip to content

Instantly share code, notes, and snippets.

@GoSubRoutine
Last active November 8, 2019 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GoSubRoutine/f5261f83d9600c495e384d9f5824a077 to your computer and use it in GitHub Desktop.
Save GoSubRoutine/f5261f83d9600c495e384d9f5824a077 to your computer and use it in GitHub Desktop.
createFileInput() for CSV
height: 25
scrolling: no
border: yes
<script async src=https://cdn.JsDelivr.net/npm/p5></script>
<script defer src=sketch.js></script>
/**
* createFileInput() for CSV (v1.0)
* GoToLoop (2019-Feb-18)
*
* https://Discourse.Processing.org/t/load-csv-file-with-createfileinput/8488/6
* https://Bl.ocks.org/GoSubRoutine/f5261f83d9600c495e384d9f5824a077
*/
"use strict";
let csv;
function setup() {
noCanvas();
createFileInput(gotFile);
}
function gotFile(f) {
print(`File "${f.name}" of type "${f.type}" was chosen.`);
if (f.name.endsWith('.csv')) return csv = loadTable(f.data, 'header', print);
console.warn("However it isn't a CSV file!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment