Table objects store data with multiple rows and columns, much like in a traditional spreadsheet. Tables can be generated from scratch, dynamically, or using data from an existing file.
Syntax
p5.Table([rows])
Parameters
An array of p5.TableRow objects
Fields
An array containing the names of the columns in the table, if the "header" the table is loaded with the "header" parameter.
An array containing the p5.TableRow objects that make up the rows of the table. The same result as calling getRows()
Methods
Use addRow() to add a new row of data to a p5.Table object. By default, an empty row is created. Typically, you would store a reference to the new row in a TableRow object (see newRow in the example above), and then set individual values using set().
If a p5.TableRow object is included as a parameter, then that row is duplicated and added to the table.
Removes a row from the table object.
Returns a reference to the specified p5.TableRow. The reference can then be used to get and set values of the selected row.
Gets all rows from the table. Returns an array of p5.TableRows.
Finds the first row in the Table that contains the value provided, and returns a reference to that row. Even if multiple rows are possible matches, only the first matching row is returned. The column to search may be specified by either its ID or title.
Finds the rows in the Table that contain the value provided, and returns references to those rows. Returns an Array, so for must be used to iterate through all the rows, as shown in the example above. The column to search may be specified by either its ID or title.
Finds the first row in the Table that matches the regular expression provided, and returns a reference to that row. Even if multiple rows are possible matches, only the first matching row is returned. The column to search may be specified by either its ID or title.
Finds the rows in the Table that match the regular expression provided, and returns references to those rows. Returns an array, so for must be used to iterate through all the rows, as shown in the example. The column to search may be specified by either its ID or title.
Retrieves all values in the specified column, and returns them as an array. The column may be specified by either its ID or title.
Removes all rows from a Table. While all rows are removed, columns and column titles are maintained.
Use addColumn() to add a new column to a Table object. Typically, you will want to specify a title, so the column may be easily referenced later by name. (If no title is specified, the new column's title will be null.)
Returns the total number of columns in a Table.
Returns the total number of rows in a Table.
Removes any of the specified characters (or "tokens").
If no column is specified, then the values in all columns and rows are processed. A specific column may be referenced by either its ID or title.
Trims leading and trailing whitespace, such as spaces and tabs, from String table values. If no column is specified, then the values in all columns and rows are trimmed. A specific column may be referenced by either its ID or title.
Use removeColumn() to remove an existing column from a Table object. The column to be removed may be identified by either its title (a String) or its index value (an int). removeColumn(0) would remove the first column, removeColumn(1) would remove the second column, and so on.
Stores a value in the Table's specified row and column. The row is specified by its ID, while the column may be specified by either its ID or title.
Stores a Float value in the Table's specified row and column. The row is specified by its ID, while the column may be specified by either its ID or title.
Stores a String value in the Table's specified row and column. The row is specified by its ID, while the column may be specified by either its ID or title.
Retrieves a value from the Table's specified row and column. The row is specified by its ID, while the column may be specified by either its ID or title.
Retrieves a Float value from the Table's specified row and column. The row is specified by its ID, while the column may be specified by either its ID or title.
Retrieves a String value from the Table's specified row and column. The row is specified by its ID, while the column may be specified by either its ID or title.
Retrieves all table data and returns as an object. If a column name is passed in, each row object will be stored with that attribute as its title.
Retrieves all table data and returns it as a multidimensional array.