createFileInput() for CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
height: 25 | |
scrolling: no | |
border: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script async src=https://cdn.JsDelivr.net/npm/p5></script> | |
<script defer src=sketch.js></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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