outContainer in Python

fHello everyone,

I'm new in Knime, and I was trying to use jPythonScript 1:1 node.

I occurs problem, when I was trying to add row to the outContainer.

As an input table I have 3 rows, as an output I would like to have 20 rows, but when I trying to create new Row and add it to outputTable I've got problems. I've read that such method AppendedColumnRow() just only append column to specified row right? So what should be method used to create new rows in outContainer (outputTable)

letters = ["a","b","c","d"]

l=0

for i in letters:

    newStringCell = StringCell(i)

    key = RowKey.createRowKey(l++)

    newRow = AppendedColumnRow(key, [newStringCell])

    outContainer.addRowToTable(newRow)

For other people, who will met such problem,

solution is very easy, AppendedColumnRow have to had DataRow representation. You have to remember of number of input columns and output columns. Problem occurs when You have e.g. 3 inputColumns, You have to remeber to put values in right direction. (That was main problem in my case). Example (for 2 columns input and 3 columns output) is as follows:

cell = inData0.iterator.next().getCell(inputColumnIndex)

i=1

while i < 10:

    string = "Test KnimeTech message"

    newStringCell = StringCell(string)

    key = RowKey.createRowKey(int(i))

    row = DefaultRow(key, [newStringCell])

    newRow = AppendedColumnRow(row, [cell])

    outContainer.addRowToTable(newRow)

 

I hope that this will be helpful to others.