Extract the column and row number for a table/matrix?

Hello KNIME community,

I am fairly new to KNIME and I need help extracting data from a table/matrix. I currently have a 100 x 100 .txt file of numbers ranging from 1-10 for each entry. I am interested in entries with values ranging from 1 to 5. Is there any way to use KNIME to find the row and column number for each entry corresponding to this criterion? I want to keep the original table intact. I just need to know where these entries are in the table based on their row and column number. I apologize if this is an ignorant question. I looked through the forums, but could not find a question asking this. I greatly appreciate your help!

Hi,

cell1

Input:
cell2

Output:
cell3

I used this expression in “Column Expressions” node:

if (column(variable("currentColumnName")) <= 5) {
join(rowId(), ", ", variable("currentColumnName"))
}

Please let me know if this is what you were looking for.

Best,
Armin

solution

4 Likes

An alternative is to use the Unpivot node to put all your table contents in one column, with the original RowIDs and ColumnIDs as the other two columns. Then you can follow this up with a Row Filter to get the values between 1 and 5, together with their respective positions.

(The Pivot/Unpivot nodes are extremely powerful and I seriously regret not learning them during my first few years with Knime)

6 Likes

This is exactly what I want! I’m having trouble getting the workflow to give the output I want. Could you help? I have attached screenshots of the workflow node settings below.

Table Reader with a sample of data:

If I force inclusion of the column on the Column Loop node like this:

I get this output:

On the other hand if I go this way with the node :

I get :

If I use either of the outputs and move on to the Column Expressions node I get:

I’m really sorry, could you please attach screenshots of the exact node settings you used? I know it’s extra trouble, but I greatly appreciate it!

My last screenshot didn’t show the error:

Oh, I didn’t tell you this one:

After including columns in “Column List Loop Start” node and applying the expression in “Column Expressions” node, you have to include only the column produced by Column Expressions node (I suggest to rename the column).

To do that check the enforce inclusion option in “Column Filter” node and include the column.

And in Row Filter node exclude missing values in this new column.

Best,
Armin

1 Like

It works perfectly!!! Thank you so much!

1 Like