Some sort of loop?

Hello,

Something quite simple I hope, struggling to find the nodes that would transform the 1st column into the 2nd column. Would like to keep it to KNIME configurable nodes only if possible. Column one is several thousand rows long.

Column 1 Column 2
1 1
1 1
1 1
1 1
1 1
1 1
1 1
0 2
1 2
1 2
1 2
1 2
1 2
1 2
0 3
1 3
1 3
1 3
1 3
1 3
1 3
0 4
1 4
1 4
1 4
1 4
1 4
1 4
0 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
0 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
0 7
1 7
1 7
1 7
1 7
1 7
1 7
1 7

Many thanks in advance,
Yush

Hi,
as I recently learned from @ipazin, you can use the Column Expressions node for that. You have to use following expression:

var i;
if (i == null) {
    i = 1;
} else if (column("column1") == 0) {
    i += 1;
}
i

Kind regards
Alexander

5 Likes

Thanks Alexander, this is perfect.

1 Like

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