Row Splitter problem

Dear Knimers,

I just ran into a situation where I have a Row Splitter, configured with “Include Rows by number”. The Row Splitter is in a loop, and in the first iteration of the loop I want 0 rows to the top outport, in the next iteration just the top row, in the next the 2 top rows, etc.

This fails because the Row Splitter does not accept a situation where the “First row number” setting (in this case 1) is higher than the “Last row number” setting (I tried to set this to 0 via a flow variable). This is odd, because in regular programming it is not uncommon to have a situation like:

for(int t=1; t<=q; t++) { }

…where the loop would be intentionally skipped when q==0.

Best
Aswin

Edit: a workaround is not hard but would be less elegant in my opinion

Hi Aswin,
you are right! I think the problem here is that the users enter the row numbers starting with 1, while internally and via flow variable the first row is 0. The check should actually compare the 0 to 1 - 1 and then not fail.
Kind regards,
Alexander

Dear @AlexanderFillbrunn ,

Yes this difference between addressing row numbers with flow variables (where 0-based indexing is used) and via the GUI (1-based indexing) is super confusing! I actually did it correctly in my workflow but made a mistake in my post.

What i wanted to do in my workflow is to take the “currentIteration” flow variable (which is 0) for the first iteration), subtract 1 and put the result (which is -1) in a new flow variable “endRow”. In the Row Splitter config, i insert the value of “endRow” into RowRangeEnd in the Flow Variables tab. From the perspective of the GUI config window, the First row Number is now 1 and the Last row number is now 0. I would like this to yield 0 lines in the top outport. This is not what happens unfortunately; what does happen is that i get everything in the top outport and nothing in the bottom outport.

Essentially, my problem is that in the “include rows by number” section of the “Row Splitter” and the “Row Filter” nodes there is no way of including 0 rows.

Best
Aswin

Hi,
I agree! One probably easier solution for your problem is to use the Row Sampling node with the option “Take from top”.
Kind regards,
Alexander

2 Likes

Great suggestion, thanks!

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