Loops and string manipulation pairwise with columns

In my dataset, I have pairs of columns corresponding to two attributes:

attribute1[a], attribute2[a], attribute1[b], attribute2[b]

I’m using a String Manipulation node to join the relevant pairs of data from the column headers to make a new column with the merged data.

attribute1[a] - attribute2[a]

I’d like to automate this since there are multiple pairs. I’ve followed a few examples doing math on columns one at a time, but can’t modify this to enable multiple columns to be manipulated together simultaneously. Is this possible using Knime?


Welcome to the KNIME Forum! It’s possible with some flow variables. You can use the Extract Column Header node to find all columns, then using some string manipulation you can extract the [a] part into a separate column. Then GroupBy that column and aggregate the original column name using the method “List”. Then expand the list into columns using Split Collection Column and then again a String Manipulation node to build the actual expression you want to use to join the two column values. Then use a Table Row To Variable Loop Start to loop through the list of expressions and in the loop you need a String Manipulation that executes the expression to create the new column. If you give me some example data, I can also build a workflow for you, but maybe you like the challenge to do it on your own :wink:
Kind regards,


Thank you for your reply.

That seems like a really great starting point for me to try and put a workflow together.

I wanted just that I clarify to make sure I was being clear in what I’m trying to do (see below).

Yes, this is how I understood it. The approach I outlined should work. Let me know if you hit a bump in the road!
Kind regards,

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