String Replacer Issue with automation

In an excel file a column has a huge amount words that is to be replaced by a particular word
I have used the string replacer node where I manually put all the words to be matched.

Is there a way in which I can upload a file with all the words to be matched ?

Hello @Ummehaani,

and welcome to KNIME Community!

Not really. String Replace (Dictionary) node is a bit old and never really featured substring replacement. However simple workaround is to read list of words into KNIME and make a flow variable out of it (word1|word2|word3|...) using GroupBy and String Manipulation nodes. Then use this flow variable in String Replacer node. You can follow approach from here:

Give it a try and if any questions feel free to ask.

Br,
Ivan

7 Likes

Thanks alot @ipazin , it worked.
I have one more query, now since I have, 11 different substring replacements

Eg: Flow variable 1- word1|word2|word3 to be replaced by A
Flow variable 2- word4|word5|word6 to be replaced by B
and so on up to 11 such flow variables

Now to do the substring replacement using these flow variable, I need 11 string replacer node.

Is it possible to do this using less nodes.
Thanks for your help :slight_smile:

Hello @Ummehaani,

of course. You need a (recursive) loop where each iteration will have a different value (replacement rule) of same flow variable used in String Replacer node. Here is example of recursive loop in KNIME (that demonstrates string replacements):

And please, if you don’t find valuable opening same issue/question in multiple topics don’t do it. Be patient. Answer will come :wink:

Br,
Ivan

2 Likes

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