Concatenate variables in a loop as string into a new table with one row

Hello there, can someone please help me with the following?

I have a table with one column containing a constant value and another containing random strings.
Is there a way in which I can create a new table with just one row containing the constant value from the first column and all the concatenated values from the second column in a second column?

In other words, I want to go from:

P-number Character
P99999 a
P99999 b
P99999 c
P99999 d
P99999 e
P99999 f
P99999 g
P99999 h

To
P-number Concatenated characters
P99999 a;b;c;d;e;f;g;h

I have tried using a loop and the String Manipulation node, but no matter what I do, I always end up with the following result:
P-number Concatenated characters
P99999 a;h

Please see the attached workflow for an example of what I have come up with so far.
Loop_Concatenate_ColumnValues.knwf (16.1 KB)

(By the way, I have tried using the Column Expressions node instead of the String Manipulation node, but it gives me the same result)

Any help would be much appreciated, thank you very much in advance!

Hi @Rehtse

Welcome to the KNIME Community!

That’s a job for the groupBy node whereby P-nummer is the grouping column and Characters is used to concatenate all the rows belonging to that group.

Choose the delimiter as you like:

Final output again:
image

1 Like

@ArjenEX : what a brilliant solution, thank you so much!

1 Like

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