I need some help with dynamically renaming column name inside “Column List Loop Start” loop.
In the attached workflow I am using multiple Math Formula nodes to perform a particular operation on each of the five columns Ret1, Ret2, …, Ret5, the resulting columns are appended to the table as R1, R2,…,R5 respectively.
Subsequently, I tried to repeat the same operation using Math Formula inside Column List Loop Start node and I am able to get the desired operation being performed on all five columns Ret1, Ret2,…, Ret5. However, I am unable to rename the appended columns as R1, R2,…,R5. Therefore, it is resulting in duplicate column names of Ret1 (#1), Ret2 (#1),…,Ret5 (#1).
Is there a way to dynamically name the appended columns inside the loop itself? So that I don’t have to manually rename all the duplicate columns again using column rename node.
Column_Rename_Inside_Loop.knwf (25.5 KB)
I’ve attached the improved version of your workflow in which you’ll get your required output.
I’ve added a “String Manipulation” node to create the column names you wanted based on the current column name and the current iteration number (+1). Then I converted the created column for the column names to variable by using “Table Row to Variable” node and then used the variable to rename the columns in column rename node. And finally I filtered the additional column (which contains the column name) to make everything tidy.
do you know about the Multi Column Math Formula node?
Yeah, that’s the best solution for his primary issue that I forgot to pay attention to.
But regarding the topic I suggested a solution to his secondary issue renaming the column names inside a loop. (I think that will help people when they search forum for a issue similar to the topic)
Thanks @Iris .
@armingrudd I always suspect there is a reason why someone is not using a node, maybe it is missing a feature
@armingrudd your solution worked perfectly for my problem. Thanks for taking the time
@Iris Yes i guess the Multi Column Math Formula node would have worked in general, except in this case I wanted the flexibility of naming the appended columns in a particular way. The multi column math formula node would only allow me to append selected column with suffix. Operationally it would provide the desired manipulation.
I am attaching the updated workflow showing both the suggested methods for benefit of the forum
Column_Rename_Inside_Loop.knwf (34.3 KB)
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.