The String Manipulation (Multi Column) node is an extension of the String Manipulation node, applying the provided expression to every selected column in turn. This can be used to search and replace, compare, or concatenate strings in multiple columns at once.
In each iteration, one column name from the selection will be used as replacement for the
$$CURRENTCOLUMN$$
placeholder in the expression. For instance, when selecting columns
first_name
and last_name
, the expression capitalize($$CURRENTCOLUMN$$)
would
first evaluate capitalize($first_name$)
and then capitalize($last_name$)
.
replace($$CURRENTCOLUMN$$, "Old", "New")
searches for "Old" and replaces with "New" in all selected columns.
join($$CURRENTCOLUMN$$, $Unit$)
appends the string in the Unit
column to each string in the selected columns.
When selecting the Freeze
and Boil
columns and appending the results as new columns, the following table could result:
Freeze | Boil | Unit | Freeze with Unit | Boil with Unit |
---|---|---|---|---|
0 | 100 | ˚C | 0˚C | 100˚C |
32 | 212 | F | 32F | 212F |
273.15 | 373.15 | K | 273.15K | 373.15K |
You can use the value of an integer column to control integer parameters of a string manipulator:
substr($$CURRENTCOLUMN$$, $Start Position$)
extracts the substring of $$CURRENTCOLUMN$$
that starts at offset k, where k is the integer value in the column Start Position
in the
current row. For example, when the selected column is Customer
and the results are appended as
Customer Name Only
, the expression substr($$CURRENTCOLUMN$$, $Start Position$)
could be
used to generate the following ouput:
Customer | Start Position | Customer Name Only |
---|---|---|
Mr. Jones | 3 | Jones |
Prof. Desmond | 5 | Desmond |
Flow variables can also be used to control the parameter of a string manipulation function. For instance, if there
is an integer flow variable start-position
available, the above example could be rewritten as
substr($$CURRENTCOLUMN$$, $${Istart-position}$$).
toNull(replace($$CURRENTCOLUMN$$, "N.A.", ""))
searches for "N.A." in all selected
columns, replaces them with "" and returns a missing value, if the resulting string is empty (toNull
converts empty strings to a missing value). For multiple strings to replace, a regular expression separating the
target strings with |
can be used: regexReplace($$CURRENTCOLUMN$$, "N.A.|-", "")
. This
replaces both occurrences of "N.A." and "-" with empty strings.
$$CURRENTCOLUMN$$
. Dynamically referenced means that $$CURRENTCOLUMN$$
refers to
different columns, depending on the columns that are selected in the column filter. It is allowed to include
non-string columns from the column filter, but their values will be converted to string before substituting them for
$$CURRENTCOLUMN$$
.age
can be referenced as $age$
. Values will
not automatically be converted to string. If necessary, convert to string, e.g., string($age$)
.null
or be skipped entirely, simply returning
a missing value for the output.toInt()
on a column that contains "1", "2", "zebra",
"4", "5" would fail on the third row). The default behavior is to stop execution, but disabling this option will output missing
values instead.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.
To use this node in KNIME, install the extension KNIME Javasnippet from the below update site following our NodePit Product and Node Installation Guide:
A zipped version of the software site can be downloaded here.
Deploy, schedule, execute, and monitor your KNIME workflows locally, in the cloud or on-premises – with our brand new NodePit Runner.
Try NodePit Runner!Do you have feedback, questions, comments about NodePit, want to support this platform, or want your own nodes or workflows listed here as well? Do you think, the search results could be improved or something is missing? Then please get in touch! Alternatively, you can send us an email to mail@nodepit.com, follow @NodePit on Twitter or botsin.space/@nodepit on Mastodon.
Please note that this is only about NodePit. We do not provide general support for KNIME — please use the KNIME forums instead.