Add columns in Knime with specific indices

Hello I’m new to Knime and i’m trying to do some simple tasks and i’m having a hard time figuring out what’s possible with what tools…

So basically this is my detailed question : how do i do this in knime: for the first 9 columns in a table, add each column with the column of index (current_column index * 9) and the column of index (current_column index * 9 * 2).
I have seen so many ideas for this, from groupby to math formula (multiple columns) to rule engine, i’m not sure if any of these can do what i want specifically because they don’t have a function to get the current_column index or to retrive columns by index, can someone help me out ?

Edit, I think i have found a simpler solution, split the table into three tables, (1-9, 10-18, 19-27) and then add them all together, but now i’m looking for a node that does that

There is a table splitter node
Concatenatting tables is done by concatenate
br

Hi @YazanALJ , one of the problems is that having split the table using something like Table Cropper (which can be used to split by column number), it is tricky to concatenate, or “stack” the sub-tables because you need to ensure they each have the same column names. It would be a lot easier and simpler if the Concatenate node could concatenate table columns positionally but unfortunately that option is not there currently. (I live in hope! :wink: )

As a result you need to do some extra work to fix the column names. I have uploaded a workflow with a variety of possible solutions. There may be other options that I haven’t considered…

2 Likes

Hello takbb, thank you kindly for providing this workflow I didn’t know about the table cropper (I discovered something similar though, a node from an extension that splits a table by column index : Column Filter (by Index) – KNIME Community Hub ), and your Replace Table column names is gonna be useful for many other worlflows.
it’s great but I apologize because I didn’t ask my question clearly, what I wanted was to literally add the three final tables together, each cell mathematically added with the other two cells in the same position in the other two tables. So if the original was 20 rows long, the final table would also be 20 rows long. I strongly think this is trivial to do so I’ll mark your answer as the solution :smile:, thank you again ^

2 Likes

Hi @YazanALJ , thanks for marking my post as the solution. I wonder if my matrix calculator component can assist you with your further problem.

I haven’t tried to use it recently, but in theory it can add two tables together so you’d just have to include it twice …

1 Like

I just searched for the topic for which I created the above component. You might also be interested in this general method of performing matrix calculations, proposed (earlier in that topic) by @Daniel_Weikert

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