Ruby Script 2x2

Go to Product
Executes a jRuby script, taking 2 input DataTables and returning 2 output DataTables. A simple example script is included in the dialog's text window of the Script tab.

This node uses Ruby-wrapper. See knime.rb at ruby4knime

Also, you can include additional gems from an external jRuby installation. But before that do setup jRuby path in preferences.

Options

Script output

Append columns to input table spec
If checked, the columns as given in the list are appended to the input table specification. 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 exactly the same number of 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.

Script

$input_datatable_arr
Array of input data tables.
$num_inputs
Number of input data tables.
$in_data_0
The input DataTable containing all available input from input port 0.
$in_data_1
The input DataTable containing all available input from input port 1.
$output_datatable_arr
Array of output containers.
$num_outputs
Number of outputs.
$out_data_0
Output container housing the outgoing DataTable for output port 0. The same as $outContainer.
$out_data_1
Output container housing the outgoing DataTable for output port 1.
Example use to copy all input row of DataTable:
(0..1).each do |i|
  out = $output_datatable_arr[i]
  $input_datatable_arr[i].each do |row|
    out << row
  end
end
Example use to extend input rows by new columns:
  count = $in_data_0.length
  $in_data_0.each_with_index do |row, i|
    $out_data_0 << (row << Cells.new.string('Hi!').int(row.getCell(0).to_s.length))
    setProgress "#{i*100/count}%" if i%100 != 0
  end
Example use to create new DataTable from custom data:
  $in_data_0.each do |row|
    $out_data_0 << Cells.new.string(row[0].to_s.length.to_s)
  end

Input Ports

Icon
Table that the Ruby script will operate on.
Icon
No description for this port available.

Output Ports

Icon
Table containing the results of the Ruby script.
Icon
No description for this port available.

Popular Predecessors

  • No recommendations found

Popular Successors

Views

This node has no views

Workflows

Links

Developers

You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.