Table content model

The table content model provides a simple model for accessing simple row and column data. The values in a particular column must all have the same type of storage (for example, strings or integers).

API

Table 1. API
Return Method Description
int getRowCount() Returns the number of rows in this table.
int getColumnCount() Returns the number of columns in this table.
String getColumnName(int columnIndex) Returns the name of the column at the specified column index. The column index starts at 0.
StorageType getStorageType(int columnIndex) Returns the storage type of the column at the specified index. The column index starts at 0.
Object getValueAt(int rowIndex, int columnIndex) Returns the value at the specified row and column index. The row and column indices start at 0.
void reset() Flushes any internal storage associated with this content model.

Nodes and outputs

This table lists nodes that build outputs which include this type of content model.

Table 2. Nodes and outputs
Node name Output name Container ID
table table "table"

Example script

stream = modeler.script.stream()
from modeler.api import StorageType

# Set up the variable file import node
varfilenode = stream.createAt("variablefile", "DRUG Data", 96, 96)
varfilenode.setPropertyValue("full_filename", "$CLEO_DEMOS/DRUG1n")

# Next create the aggregate node and connect it to the variable file node
aggregatenode = stream.createAt("aggregate", "Aggregate", 192, 96)
stream.link(varfilenode, aggregatenode)

# Configure the aggregate node
aggregatenode.setPropertyValue("keys", ["Drug"])
aggregatenode.setKeyedPropertyValue("aggregates", "Age", ["Min", "Max"])
aggregatenode.setKeyedPropertyValue("aggregates", "Na", ["Mean", "SDev"])

# Then create the table output node and connect it to the aggregate node
tablenode = stream.createAt("table", "Table", 288, 96)
stream.link(aggregatenode, tablenode)

# Execute the table node and capture the resulting table output object
results = []
tablenode.run(results)
tableoutput = results[0]

# Access the table output's content model
tablecontent = tableoutput.getContentModel("table")

# For each column, print column name, type and the first row
# of values from the table content
col = 0
while col < tablecontent.getColumnCount():
     print tablecontent.getColumnName(col), \
     tablecontent.getStorageType(col), \
     tablecontent.getValueAt(0, col)
     col = col + 1
The output in the scripting Debug tab will look something like this:
Age_Min Integer 15
Age_Max Integer 74
Na_Mean Real 0.730851098901
Na_SDev Real 0.116669731242
Drug String drugY
Record_Count Integer 91