Combining columns into a collection/list

Hi,

I have to merge 20 columns, they are named;

colName1
colName2
colName3
colContent1
colContent2
colContent3
etc

So, I need to create a collection of colName1 + colContent1, colName2 + colContent2 etc

How do I do this ?

There are 20 named columns, with 58K rows of data. I just can’t figure out the best approach to this, I have tried using a recursive loop, but I can’t figure out how to combine the respectively numbered columns to create the collection / list

Thanks,

Rich H

Hi @stanage

Did you check the Column Aggregator node?
gr. Hans

Hi,

I did use column Aggregator and Ungroup node, which works great for a single colName1 + colContent 1 but how do I cycle through all column combinations to create the respective collections

colName1 + colContent1
colName2 + colContent2
etc

1 Like

Hi @stanage

To me, it is not quite clear what you want to achieve.
Do you have some sample input and the output that you expect ?
gr. Hans

Hi @stanage , you can use the Create Collection Column node for what you are trying to do:

It allows you to select the columns you want to create a collection from


The above table contains columns, so I need to combine the columns based on their specific number, so
CDSName2 + CDSSeq2 are combined,

then

CDSName3 + CDSSeq3 are combined

then
CDSName4 + CDSSeq4 are combined

etc

How do I group the columns on the number in the column name ?

Hi @stanage

I created this wf combining_columns.knwf (63.0 KB).
The tricky part is to pass the right set of columns into the chunk loop. There is no automatic check for it in this flow. See if it helps you towards solving this problem.


gr. Hans

3 Likes

Hi Hans,

Very much appreciated. The workflow works and has combined the columns as expected. I never thought of reversing the column name, and use of the chunk loop, excellent. Thanks for the quick response.

Stanage

1 Like