Transform matrix into single row values

Hello forum!

I am quite new to knime, and I need your help.

I am trying to transform a matrix like this one:

image

And I want to obtain a list like below:
C1 - R1 - 1
C1 - R2 - 1
C1 - R3 -
C1 - R4 - 5
C2 - R1 - 0
C2 - R2 - 1
…

And so on.

I have checked forum and I haven’t found anything similar. I apologize if it is a “silly” question or if it has been already answered.

Thanks in advance.

Best regards,

Hi @snat

Welcome to the KNIME forum. Good you ask this! There are no silly questions. See this workflow matrix_to_single_row.knwf (24.3 KB)
matrix
If any question feel free to ask.

gr. Hans

4 Likes

Hi @snat and welcome to the KNIME community forum,

The Unpivoting node is what you are looking for.

:blush:

P.S. I agree with @HansS, “there are no silly questions”. Here, we are all learning from each other.

4 Likes

Thank you very much to both of you for your quick response! :slight_smile:

I tried with unpivoting before asking to the forum, but I didn’t succeed, so I have followed Hans’ suggestion. I just need to add the combination of columns/rows name/header to the values, but I can manage it by myself :wink:

Best regards!

2 Likes

You have to include all the columns as the “Value columns” and exclude them from “Retained columns”:

Then if you sort the table by “ColumnNames” this would be the output:

unpivot0

:blush:

3 Likes

Thanks again @armingrudd !

With your screenshots and playing a little bit with settings of file reader (for reading row ID/column header) I have managed to get something very close to what I need.

Now I know how to do that in 2 different ways :smiley:

Best regards,

4 Likes

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