Reputation: 39
Is there a way to access a p5.js table object row using a string - similar to accessing a table column using its header?
For example, the following csv table contains greeting and parting in different languages:
,EN, FR
greeting, hello, bonjour
parting, goodbye, aurevoir
I want to print 'hello' without using row or column index numbers, just strings:
var table = loadTable(greet-part.csv', 'csv', 'header');
print(table.get("greeting", "EN"));
I could write some more code linking 0 to 'greeting', 1 to 'parting' etc but this would become cumbersome on a large scale:
Ideas for a more elegant solution?
Upvotes: 2
Views: 146
Reputation: 51867
You could try findRow()
.
Not, tested, but in you case you could try something like:
table.findRow("greeting", 0).get("EN");
Upvotes: 2