I would like to know how to perform ‘recursive loop’. Recursive loop means getting data table from the result in loop calculation and continue calculation until the specific condition met. Of cource, the first data table from out of the loop to start the loop is needed.
Is there any way to meet this issue?
Thank you for your help in advance.
I guess, you can use the Variable Condition Loop End node together with any Loop Start node, for example Generic Loop Start. From a second branch, I would suggest inputting the data into the node under consideration between loop start and loop end node where the actual loop-end condition (variable) is calculated.
Sorry, I must withdraw my previous post. I eventually missed the important part of your question. With the current collection of Loop Support nodes, I don't see a smooth way to perform a recursive loop. But I still think it's possible (or better you can workaround it). My proposed solution reads as: the main-branch loops the variable or condition validated in the Loop End node, and a side-branch that get's the data from a data source (e.g. KNIME table, CSV file, ...) where the initial data (iteration=0) delivers the data from original data and injects it to the main-branch. Note, the input note needs to connected to the Loop Start node using the flow variable ports to get reset for each iteration. Just before the Loop End node, you can have a KNIME table writer or CSV writer (corresponds to the mentioned Reader node) that writes out the data of the current iteration. Then the next iteration will start with the Loop Start node and after that immediately reads in the modified dataset from the previous iteration. Does this help?
Thank you for your immediately and detailed response.
I understand your solution as that; main loop is responsible for the iteration how many times it must be continued and side loop for data processing. Recursive data process is realized by delivering data table with file using CSV writer and CSV reader. It sounds tricky but very simple and easy to create flow.
I will try for it. Thank you!
Regards, Kouichirou Hori
I set the “File Reader” after the loop start node and “CSV Writer” just before the loop end node as shown below. So, I hope the data in the loop would be refreshed.
some nodes -------- File reader
some nodes -------- CSV writer
Unfortunately, “File Reader” was not refreshed and data in the first iteration was conserved. As you know, “File Reader” node is not refreshed automatically in the loop.
Are there any solutions with this problem?
In order to force the File Reader being reset during the loop iterations, you need to connect the variable out-port from the Loop Start with the variable in-port of the File Reader. Those ports are only visible in the expert node and need to manually enabled using the node context menu.
I have the same issue with a node "List files". Attached is a zip. I tried your suggestion but could not connect the out[port from the Loop Start with the variable in-port of the "List files" node, though I have enabled the ports to be visible.
I am not sure you are trying to achieve the same thing that is discussed in this post. To me it looks like you are reading a bunch of CSV-files that are all in the same format. In that case, all you need to do is remove the concatenate node and ensure that the files have the same format.
Anyways, if you want to connect the flowvariable-out-port of the Loop Start node to the flowvariable-in-port of the List Files node, you cannot connect the out-port of the List Files node to the in-port of the Loop Start, because this would close a circle. Circles are not possible in KNIME workflows.
I hope this clears it up.