Hello, I have several columns named i.e. “2020+Origin#2684” and I need to remove the “2020+” from the name of all columns where it exists. Can someone suggest the best node and how to program it?
Thank you
Mona
Hello, I have several columns named i.e. “2020+Origin#2684” and I need to remove the “2020+” from the name of all columns where it exists. Can someone suggest the best node and how to program it?
Thank you
Mona
Hi @Mona. I’d extract the headers with a “Extract Column Header” node, connect it to a “String Manipulation” node and use ther rep function inside it. Rename the cols using the “Insert column Header” node
Thanks @iperez. I’ve tried to do what you suggested above but I’m stuck in the last few steps. I’ve attached the workflow. I can’t get the “Insert Column Header” to work. I’ve tried a few things as you can see. Can you please have a look?
Thank you
MonaInsert_Column_Header.knwf (38.7 KB)
@MJRIOUX you were almost there
Hi @MJRIOUX
The most elegant way to do this is using the Column Rename (Regex) node. But I’m not familiar with regex. So the other way to do it, is like in your workflow with the Extract Column Header. See my suggestion: Insert_Column_Header_2.knwf (63.5 KB)
gr. Hans
Hi @MJRIOUX. check this. Insert_Column_Header.knwf (59.7 KB)
Thank you everyone, I used the last solution by @iperez and it worked perfectly!
One more question though, in the “String Manipulation (Multi Column)” we have replace($$CURRENTCOLUMN$$,“2020+”,""). Is There anyway to put a wildcard in for “202*+” so that we don’t have to change the year in January every year? Or even “20**+” would be even better!
Mona
Hi @MJRIOUX. Sure just use the function: replaceChars($$CURRENTCOLUMN$$,“20**+” ,"" )
That should go OK for the rest of the century…
Hello there,
as @HansS mentioned Column Rename (Regex) is a node intended to be used in such use case. Check workflow attached. It removes everything before Origin word.
Insert_Column_Header_ipazin.knwf (63.9 KB)
Br,
Ivan
This is great @ipazin! Solves the issue with way less nodes. I don’t know Regex either but will try to learn. Thanks!
Mona
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.