StreamableKNIME Java Snippet Nodes version 4.3.0.v202011191508 by KNIME AG, Zurich, Switzerland
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
last_name, the expression
capitalize($first_name$) and then
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
Boil columns and appending the results as new columns, the following table could result:
|Freeze||Boil||Unit||Freeze with Unit||Boil with Unit|
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
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|
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
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 (
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
agecan be referenced as
$age$. Values will not automatically be converted to string. If necessary, convert to string, e.g.,
nullor 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.
To use this node in KNIME, install KNIME Javasnippet from the following update site:
A zipped version of the software site can be downloaded here.
You don't know what to do with this link? Read our NodePit Product and Node Installation Guide that explains you in detail how to install nodes to your KNIME Analytics Platform.
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.
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 email@example.com, follow @NodePit on Twitter, or chat on Gitter!
Please note that this is only about NodePit. We do not provide general support for KNIME — please use the KNIME forums instead.