Use column names from set one in set two..

Hi,
I am new to Knime , coming from Alteryx.
I have column names in one input and I want to use them as names for my data from second input.
In Alteryx there is an option to Union by position (first column from set one under first column of set two). Also I can use Dynamic Rename. Tried various tools and the closest was Column Renamer (Dictionary) but that expects names’ mapping.
Is there a simple way to do it or does it need programming? Thanks

Could you provide more detail about how your two tables are formatted? Are the column names in the first table in one column? Is the data in the second table in different columns that you want to name from the first table? Some sample data for each table would be very helpful.

HI. I have a row of column names, which I can move to header using Row To Column Names. Second set is the data, with column names like Column0_Arr[1]. I cannot provide a sample but this has to be universal anyway since the source data can have totally different columns next time. What I have is headers and data and I want to merge it in one set.

Hi @Andrzej_Majda , I’m not sure if this is what you are trying to do, but if you want to rename the columns of one table to match the columns of another table, (using the column order), I have a component to simplify this:

Here’s an example usage, for concatenating two tables positionally even though the column names are initially different.

To do the same “by hand”, you use the following pattern (which is exactly what that component does)

I could never remember the pattern (especially after the KNIME devs renamed half the nodes it used! :wink: ), hence I created the component!

The above component handles the use case where the lower table has at least the number of columns that the upper table contains. If however, there is a chance that the lower table has fewer columns, the component will fail. If this scenario is a possibility, you can use an alternative component:

It does the same job but is slightly more “heavyweight”. You can configure to handle a shortage of columns by simply renaming as many as it can positionally, and leaving the rest alone.


If that’s not what you’re looking for, please elaborate further.


btw, I have long felt that it would be a great feature for the Concatenate node to have the positional option that is available in the Alteryx Union tool, though I suspect I never got round to raising it as a suggestion, but unfortunately it doesn’t.

Welcome to the KNIME forum!

2 Likes

Hi takbb. That is exactly what I needed! Case closed.
In this case it must (hopefully…) be 1:1 meaning headers and data have the same number of columns. I am parsing that from source file which has a fixed format but the headers need special treatment separately. And it is great that you provided the “by hand” example, did not think of that solution… It is also nice that I can just copy a new component from a forum, this is cool.

But yes, I share your frustration with the official nodes - it seems that they are thought of in a particular way and if you need something a bit different you do not have a way to manipulate them in any way, which granted is the same way in Alteryx but i feel that there are more options available there.

1 Like

Glad it worked for you @Andrzej_Majda , and thank you for marking the solution.

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