i have written a code in the method body (see below).
textField = $Januar$.replace(“<0,001”,“1”);
textField = textField.replace(“n.b.”,“1”);
But just want not only use in this case the month January but many other columns too like February, March etc.
But I cannot find the settings in this node and also the right instruction to replace a text in several columns.
Welcome to the KNIME Forum! For the Java Snippet (simple) that is difficult, but these simple replacement operations can also be performed using the String Manipulation (Multi Column) node. That should do the trick!
thanks for the fast answer. I tried it before (see below).
But I couldn’t find a way to put more instructions than one single replace instruction. How can I put more than 1 instruction to these following one single line?
Thanks a lot.
You can simply nest multiple function calls. Like this:
replace(replace($mycol$, "ABC", "DEF"), "XYZ", "123")
I saw this answer with the nest multiple function in the forum too. But I have round about 8-10 multiple function calls to replace. The nesting possibility would not look very clear in this case. Is there not an easier way?
I agree nesting so many functions may be a bit messy. But if you format it like this, it might just be ok:
Otherwise, you can probably solve this using a Column List Loop Start node to loop through your columns and then apply the Java Snippet. You will need to play around with flow variables a bit to make it work, though.
wonderful. It works. Thanks a lot for your fast answers. I will try the Column List Loop Start possibility later, too. But this day was a good day.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.