# Loop X times based on number of rows in a table

Or more specifically, based on the change in the number of rows in a table.

I have strung together a few nodes in a workflow that compare adjacent rows in a table and then remove rows that are too similar to the ones immediately preceding them.  However a single iteration of these nodes is seldom sufficient to get rid of all the rows that are too similar to one another, hence I run them several times.

Therefore I would like to set up a loop where at the start of each iteration, it takes the length of the table, then at the end of the iteration it takes the table length again.  If the length at the end was the same as the length at the start, then exit the loop and move on.

I've looked at using "Extract Table Dimension", "Table row to variable", and "String Manipulation" to get the row count of a table.  However I can't find a way to do this at both ends of the loop - so that the two lengths can be compared - and it's not clear to me how I could use these in a loop and still do the operations I need on the table in question (as "Extract Table Dimension" creates a new table).

Any suggestions are appreciated.

thank you

I think you want to use a Recursive Loop End node. Have a look at that and come back if you can't figure out a solution.

From my understanding once I tried to use the Recursive Loop End node that you suggested, it seems that one is for doing a known number of loops.  In my case, I don't know how many loops I will need to run (I apologize if my initial post did not make that clear).  The criteria that I want to use to determine when to finish the loop is the difference in table lengths between the start and end of the loop.

I then tried "Generic Loop Start" and "Variable Condition Loop End" (where I set a variable in the loop that reported the difference I was looking for), but I ran into a different problem with this.  When I set this up, every time the loop began again it began with the original table rather than the one that was reduced in the previous iteration.  Hence I know have an infinite loop, which was not what I was looking to do.

Any other ideas would be much appreciated.

thank you

Hello,