STRING MANIPULATION

Good morning people, everything fine ?

I need your help to solve a problem, I have the ORIGIN and DESTINATION column, I need them to be one under the other on the same line, being the origin first and then the Destination. As origin number 1 and destination number 2, it includes two images below demonstrating this.


image

Hi,
You can use two parallel Column Filter nodes to get one table with DESTINO and one with ORIGEM. Them rename both to “Station Name” using 2 Column Renamer nodes (pre 5.0 this is called “Column Rename”). Now you can use a Constant Value Column to add Station Number=1 to one table and Station Number=2 to the other. Finally, add a Counter Generation node to both of them to add a counter, then Concatenate the two tables again and use a Sorter to sort by the counter so that the right rows are below each other.
Kind regards,
Alexander

2 Likes

Alexander could you paste your workflow for me to check? I am including the table below
KNIME_project5.knwf (52.3 KB)

Hello @Gabriel2020,

proposed solution seems a bit complicated to me. Do you know about Unpivoting node? Pretty powerful, fast and seems can do the job in your case. Take a look at workflow attached.
KNIME_project5_ipazin.knwf (57.8 KB)

You don’t need Column Resorter node if you can resort your columns prior to reading data into KNIME. Anyways, usually it makes sense to first have origin and then the destination column in your data :wink:

Br,
Ivan

4 Likes

What about merging the 2 columns together as a list and then ungroup? Maybe I am thinking to easy here.
br

2 Likes

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