Replacing String With Missing value

Hello Everyone,
I have just started my KNIME journey. I know that using string Manipulation node we can change a string Value to null. I have a column PORT which has multiple strings (OTHER, NONE, To be decided) which need to be converted to missing value (null). Is it possible to use a single node to do them all together instead of using the String manipulation node many times? These are on single column not on different column .
Thanks in Advance, any pointers will be much appreciated.

1 Like

You can use Rule Engine – KNIME Hub and use the fact that if no rule matches, the result is missing.

For example:

NOT ($PORT$ IN ("OTHER", "NONE")) => $PORT$
6 Likes

Another solution would indeed be the String Manipulation.
You can always nest functions like this:
toNull(replace(replace(replace($PORT$, "OTHER", ""), "NONE", ""), "To be decided", ""))

The Rule Engine might be more convenient though :wink:

7 Likes

Thanks I used both the methods and they both worked, but like you said the Rule engine is more convenient. Also I was wondering if these values are not in caps or the string is different Like None and none can we perform the same operation using β€œNONE*”, will it work.

1 Like

The Rule Engine does not have an option to ignore case but you can use the String Manipulation node beforehand to turn everything into lower / uppercase using the
toLowercase() or toUppercase() functions.

5 Likes

Thanks help is Much appreciated

2 Likes

But regular expressions have, so you can use the (?i) modifier with the MATCHES rule:

NOT $PORT$ MATCHES "(?i)(none|other)" => $PORT$
7 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.