Skip to content

Commit 9c9a3aa

Browse files
authored
fixing loadTable
1 parent 33f73eb commit 9c9a3aa

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

src/io/files.js

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -486,33 +486,27 @@ function files(p5, fn){
486486
* @example
487487
* <div class='norender'>
488488
* <code>
489-
* // Given the following CSV file called "mammals.csv"
490-
* // located in the project's "assets" folder:
491-
* //
492-
* // id,species,name
493-
* // 0,Capra hircus,Goat
494-
* // 1,Panthera pardus,Leopard
495-
* // 2,Equus zebra,Zebra
496-
*
497489
* let table;
498490
*
499491
* async function setup() {
500-
* table = await loadTable('assets/mammals.csv', 'csv', 'header');
501-
*
502-
* //count the columns
503-
* print(table.getRowCount() + ' total rows in table');
504-
* print(table.getColumnCount() + ' total columns in table');
505-
*
506-
* print(table.getColumn('name'));
507-
* //["Goat", "Leopard", "Zebra"]
508-
*
509-
* //cycle through the table
510-
* for (let r = 0; r < table.getRowCount(); r++)
511-
* for (let c = 0; c < table.getColumnCount(); c++) {
512-
* print(table.getString(r, c));
513-
* }
514-
* describe(`randomly generated text from a file,
515-
* for example "i smell like butter"`);
492+
* // Create a 200x200 canvas
493+
* createCanvas(200, 200);
494+
*
495+
* // Load the CSV file with a header row
496+
* table = await loadTable('assets/mammals.csv', ',', 'header');
497+
*
498+
* // Get the second row (index 1)
499+
* let row = table.getRow(1);
500+
*
501+
* // Set text properties
502+
* fill(0); // Set text color to black
503+
* textSize(16); // Adjust text size as needed
504+
*
505+
* // Display each column value in the row on the canvas.
506+
* // Using an offset for y-position so each value appears on a new line.
507+
* for (let c = 0; c < table.getColumnCount(); c++) {
508+
* text(row.getString(c), 10, 30 + c * 20);
509+
* }
516510
* }
517511
* </code>
518512
* </div>

0 commit comments

Comments
 (0)