Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example for p5.Table.getArray() #2692

Merged
merged 4 commits into from
Mar 12, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/io/p5.Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ p5.Table.prototype.getNum = function(row, column) {
* @return {String}
*
* @example
* <div class="norender">
* <div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the norender class is not present, the sketch will still create a canvas but it would be empty in this particular case since nothing will be drawn on screen. Can be a bit confusing I think since most people won't have the console opened all the time.

* <code>
* // Given the CSV file "mammals.csv"
* // in the project's "assets" folder:
Expand All @@ -1120,18 +1120,21 @@ p5.Table.prototype.getNum = function(row, column) {
* var table;
*
* function preload() {
* //my table is comma separated value "csv"
* //and has a header specifying the columns labels
* // table is comma separated value "CSV"
* // and has specifiying header for column labels
* table = loadTable('assets/mammals.csv', 'csv', 'header');
* }
*
* function setup() {
* var tableArray = table.getArray();
*
* //output each row as array
* for (var i = 0; i < tableArray.length; i++) {
* print(tableArray[i]);
* }
* print(table.getString(0, 0)); // 0
* print(table.getString(0, 1)); // Capra hircus
* print(table.getString(0, 2)); // Goat
* print(table.getString(1, 0)); // 1
* print(table.getString(1, 1)); // Panthera pardus
* print(table.getString(1, 2)); // Leopard
* print(table.getString(2, 0)); // 2
* print(table.getString(2, 1)); // Equus zebra
* print(table.getString(2, 2)); // Zebra
* }
* </code>
* </div>
Expand All @@ -1140,6 +1143,7 @@ p5.Table.prototype.getNum = function(row, column) {
* no image displayed
*
*/

p5.Table.prototype.getString = function(row, column) {
return this.rows[row].getString(column);
};
Expand Down