I have 5 columns. I want to convert values of first 3 rows in to columns. So 3X5 = 15 columns. And so on. Here is an example:
|Column 1|Column 2|Column 3|Column 4|Column 5|
Any Help will be much appreciated. TIA.
Hi @richakaundal , is this something you’ll need to do often, cos if not I think copy and paste would have been faster, if not so satisfying…
If I’m understanding this correctly, you want to end up with a table of 3 rows and 15 columns. The cells in the original 9 row x 5 columns will move to the following cell positions (with columns A thru O)
I modified my initial test data to make it easier to visualise where each cell was going to be heading to…
The attached workflow achieves this. It is specific in that it is based on a known number of initial rows etc so if this is something that needs to be able to scale up, some sort of loop would be in order rather than repeating the central processing (but in my defence, it was getting late! )
However, if the requirement is only ever this specific size of input and output table, then this is perhaps a possible solution or at least a starting point…
The data set that you gave:
KNIME_Columns from Rows 2a.knwf (44.2 KB)
I have more than 1000 rows in the table , so copy paste was not an option.
I have used your logic and loop through all rows. And found solution.
Thank you for adding comments, it helped me understand how workflow is working.
Hi @richakaundal , I’m glad it assisted you’ve extended it to work across 1000 (999? ) rows!
Just kidding by the way re copy-and-paste. To be fair, a job like this would always have me reaching for a technical solution if there’s even a sniff of any danger of having to do it more than once!
I’m trying to get my head round that workflow. I like the idea of the chunk loop, but I’m trying to work out how it can work as when I tried to reproduce that, although the values went to the correct rows, they didn’t get to the correct columns.
The only way I managed to get that to generate the columns in the correct order was by modifying the String Manipulation node to create column names “out of sequence”
and then add a Column Resorter after the Loop End to put all the columns in alphabetical order…
Still, I may have missed something, and your loop greatly simplifies the original, so nice work!
Here is my take on it, if anybody wants to make use of it or improve further…
KNIME_Columns from Rows 2b -loop 2.knwf (31.7 KB)
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.