0 ×

JPython Script 1:1

KNIME JPython Scripting nodes version 4.1.0.v201911110939 by KNIME AG, Zurich, Switzerland

Executes a JPython script, taking 1 input DataTable and returning 1 output DataTable. A simple example script is included (but commented out) in the dialog's text window of the Script tab.

Currently employs jython v2.2.1.


Append columns to input table spec
If checked, the columns as given in the list are appended to the input table specification, i.e. the number of columns in the output table equals the number of input columns plus the number of columns as given in the list. If unchecked, the output table will have as many columns as given in the list.
Column list
Specify the column name and type of all result columns. After adding a new column, click on the name or type to change its value.
The input DataTable containing all available input from input port 0.
Available methods: getDataTableSpec(), iterator().
Example use to obtain DataTableSpec:
    dts = inData0.getDataTableSpec()
    input1ColumnIndex= dts.findColumnIndex("H atoms")

Example use to step through rows in DataTable:
    iterator = inData0.iterator()
    while iterator.hasNext():
        row = iterator.next()
Output container housing the outgoing DataTable for output port 0. This must be populated with rows by the script or else there will be no output from the node.
Available methods: addRowToTable(ColumnRow arg1)
Example use to iteratively create outgoing DataTable (creates duplicate of input DataTable):
    iterator = inData0.iterator()
    while iterator.hasNext():
        row = iterator.next()
ColumnIndex objects point to particular columns in the DataTable. A ColumnIndex is useful as input to other methods which need to access values in one particular column of the DataTable.
Available methods: NONE
Example use to identify the column that is labelled "Size of Shoe":
    dts = inData0.getDataTableSpec()
    shoeSizeColumnIndex= dts.findColumnIndex("Size of Shoe")
ColumnRow objects correspond to rows in the DataTable. The results from methods that return a row from a DataTable are actually returning an object of this class.
Available methods: getCell(ColumnIndex arg1)
Example use to obtain the value from a row for a column that contains strings:
    dts = inData0.getDataTableSpec()
    petNamesColumnIndex= dts.findColumnIndex("Name of Pet")
    iterator = inData0.iterator()
    row = iterator.next()
    current_name = str(row.getCell(petNamesColumnIndex))
Example use to obtain the floating-point value from a row for a particular column:
    dts = inData0.getDataTableSpec()
    petWeightColumnIndex= dts.findColumnIndex("Weight of Pet")
    iterator = inData0.iterator()
    row = iterator.next()
    current_name = float(str(row.getCell(petWeightColumnIndex)))
DataTableSpec objects contain specifications of all of the types of data currently in the DataTable.
Available methods: findColumnIndex(String arg1)
Example use to obtain DataTableSpec and then locate a particular column by its label:
    dts = inData0.getDataTableSpec()
    sunshineColumnIndex= dts.findColumnIndex("Days of Sunshine")

Input Ports

Table that the JPython script will operate on.

Output Ports

Table containing the results of the JPython script.

Best Friends (Incoming)

Best Friends (Outgoing)


To use this node in KNIME, install KNIME Jython Scripting (Legacy) from the following update site:




