-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.js
More file actions
38 lines (29 loc) · 855 Bytes
/
table.js
File metadata and controls
38 lines (29 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Given the following CSV file called "mammals.csv"
// located in the project's "assets" folder:
//
// id,species,name
// 0,Capra hircus,Goat
// 1,Panthera pardus,Leopard
// 2,Equus zebra,Zebra
// import table from "./p5/p5";
var csv;
function preload() {
csv = loadTable('earthquakes.csv', 'csv', 'header');
}
function setup() {
let table = new p5.Table();
table.addRow(new p5.TableRow)(csv.getRow(0));
//count the columns
print( + ' total rows in table');
print(csv.getColumnCount() + ' total columns in table');
print(csv.getColumn('name'));
//["Goat", "Leopard", "Zebra"]
//cycle through the table
for (var r = 0; r < table.getRowCount(); r++)
for (var c = 0; c < table.getColumnCount(); c++) {
print(table.getString(r, c));
}
}
function draw(){
ellipse(50,50,80,80);
}