Adding multiple columns at a specific location and then appending

Hi All,

I have a feeling that i’ll need a loop for this. My challenge is easier described with an example.

Capture2

The way I get to it in excel is by doing text-to-columns > then adding a copy of the primary key column before each new column > then appending the new columns > removing all blanks > then concatenating the primary key column with the numbers column to remove duplicates.

In Knime, I have cleaned up the data and done a text-to-column equivalent using the Cell Splitter Node. Now I have to manually copy the primary key column and place it behind each new column before I append, remove blanks, and remove duplicates. The number of columns after a text-to-column are not set so that complicates things as well. This is why I have a feeling I need to use some sort of loop to do this.

Thoughts? Any help would be appreciated.

Hi @rajanf -

No looping needed - just a little Unpivoting node magic, and some cleanup.

2019-04-16%2009_31_16-KNIME%20Analytics%20Platform

2019-04-16%2009_31_30-Filtered%20table%20-%204_281%20-%20Column%20Filter

UnpivotingExample.knwf (11.9 KB)

2 Likes

Thank you @ScottF this worked!

Hi @rajanf,
there is another way by using the Cell Splitter to create a list and use Ungroup on the created list. By selecting the option to remove input column no cleanup is needed.
Scott already solved this perfectly but since I could not resist to tryout the nodes I had in mind anyway, I might aswell share the alternative here :smiley:
Ungroup Example.knwf (7.5 KB)

Best regards,
Felix

3 Likes

Thank you @FelixFelicis. This works too!

I’m keeping this option in my files as well since I’m new to Knime and all this really helps to understand different permutations :slight_smile:

Cheers,
FR

1 Like

Glad to help and welcome to our community!
There are usually many more different ways to do things in KNIME and come up with the wanted result, so that is totally the right attitude to be successful at KNIMing :wink: I wish you a good start!

Best,
Felix

1 Like

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