Skip to content

Commit 707a851

Browse files
committed
scala: added code example with access to a cell by symbolic name of a column
1 parent e9c4750 commit 707a851

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

RubyScript/src/org/knime/ext/jruby/RubyScriptNodeModel.scala

+18
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ class RubyScriptNodeModel (
108108
# puts FlowVariableList['knime.workspace'] # reading
109109
# FlowVariableList['filename'] = '1.txt' # writing
110110
#
111+
"""
112+
113+
protected val templateCellAccess =
114+
"""#
115+
# For access to a cell of rows use symbolyzed names of columns.
116+
# All non letter/number symbols of a input column name are changed to underline symbol.
117+
# Names are converted in downcase. For input 0 only use direct short names. For more
118+
# then one input use a following format: i#{input_num}_translated_column_name
119+
# Example:
120+
# iter = FlowVariableList['currentIteration'] # read loop iterator value
121+
# $in_data_0.each do |row| # for all data of input 0
122+
# $out_data_0 << (row << # add existing row with all columns
123+
# (Cells.new.int(row.data1.to_i + iter))) # add new col. from 'data1' col. plus iter
124+
# end
125+
#
111126
"""
112127

113128
protected val templateSnippet =
@@ -185,6 +200,9 @@ end
185200

186201
buffer ++= templateFlowVar
187202

203+
if (numInputs > 0)
204+
buffer ++= templateCellAccess
205+
188206
buffer ++= (snippetMode match {
189207
case true => templateSnippet
190208
case _ if (numInputs > 0) => templateScriptMultiInput

0 commit comments

Comments
 (0)