Modelo de conteúdo de tabela
O modelo de conteúdo da tabela fornece um modelo simples para acessar dados de linha e da coluna simples. Todos os valores em uma coluna específica devem ter o mesmo tipo de armazenamento (por exemplo, sequências ou números inteiros).
API
| Método | Tipos de retornos | Descrição |
|---|---|---|
getRowCount() |
int |
Retorna o número de linhas nesta tabela. |
getColumnCount() |
int |
Retorna o número de colunas nesta tabela. |
getColumnName(int columnIndex) |
String |
Retorna o nome da coluna no índice da coluna especificado. O índice da coluna inicia em 0. |
getStorageType(int columnIndex) |
StorageType |
Retorna o tipo de armazenamento da coluna no índice especificado. O índice da coluna inicia em 0. |
getValueAt(int rowIndex, int columnIndex) |
Object |
Retorna o valor no índice de linha e de coluna especificado. Os índices de linha e coluna começam em 0. |
reset() |
void |
Limpa qualquer armazenamento interno associado a este modelo de conteúdo. |
Nós e saídas
Esta tabela lista os nós que constroem saídas que incluem esse tipo de modelo de conteúdo
| Nome do nó | Nome da Saída | ID do contêiner |
|---|---|---|
table |
table |
"table" |
Script de exemplo
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