0 / 0
Table content model

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. Methods for the table content model
Method Return types Description
getRowCount() int Returns the number of rows in this table.
getColumnCount() int Returns the number of columns in this table.
getColumnName(int columnIndex) String Returns the name of the column at the specified column index. The column index starts at 0.
getStorageType(int columnIndex) StorageType Returns the storage type of the column at the specified index. The column index starts at 0.
getValueAt(int rowIndex, int columnIndex) Object Returns the value at the specified row and column index. The row and column indexes start at 0.
reset() void Flushes any internal storage associated with this content model.

Nodes and outputs

This table lists nodes that build outputs that 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
Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more