Skip to content
Merged
Changes from all commits
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
52 changes: 44 additions & 8 deletions src/io/p5.Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 Expand Up @@ -1213,6 +1217,38 @@ p5.Table.prototype.getObject = function(headerColumn) {
*
* @method getArray
* @return {Array}
*
* @example
* <div class="norender">
* <code>
* // Given the CSV file "mammals.csv"
* // in the project's "assets" folder
* //
* // id,species,name
* // 0,Capra hircus,Goat
* // 1,Panthera pardus,Leoperd
* // 2,Equus zebra,Zebra
*
* var table;
*
* function preload() {
* // 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();
* for (var i = 0; i < tableArray.length; i++) {
* print(tableArray[i]);
* }
* }
* </code>
* </div>
*
*@alt
* no image displayed
*
*/
p5.Table.prototype.getArray = function() {
var tableArray = [];
Expand Down