Reference+
Name
addColumn()
Class
Table
Description
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.) A column type may also be specified, in which case all values stored in this column must be of the same type (e.g., Table.INT or Table.FLOAT). If no type is specified, the default type of STRING is used.
Examples
Table table; void setup() { table = new Table(); table.addColumn("name"); table.addColumn("age", Table.INT); table.addColumn("height", Table.FLOAT); TableRow newRow = table.addRow(); newRow.setString("name", "Jermaine"); newRow.setInt("age", 15); newRow.setFloat("height", 4.567); saveTable(table, "data/new.csv"); } // Sketch saves the following to a file called "new.csv": // name,age,height // Jermaine,15,4.567
Syntax
.addColumn()
.addColumn(title)
.addColumn(title, type)
Parameters
title
(String)
the title to be used for the new columntype
(int)
the type to be used for the new column: INT, LONG, FLOAT, DOUBLE, or STRING
Return
void
Related
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.