Help Required: Two problems: 1: Loops adding extra rows. 2: Rule engine

I am new to Knime, having following issues, please help me.

Problem # 1 : Knime loops are adding extra rows upon iterations instead of just overwriting the data. I am trying to compare a data column with another table via loop (Table Row to Variable Loop Start), the problem is that the loop runs for the number of rows in the table and add that much data-rows in original document, I just want the overwritten data not the data after each iteration.

Problem # 2: I defined a rule in the rule-engine to add specfic data in the column if the condition is met, but the problem is that the rule engine removes the data from the column if the condition is not met [Makes the cell empty]. Is it supposed to work like this ? as it should only add the data in case the condition is matched not to remove all other data in the row.

Thanks.

Hi @nikola_tesla and welcome to the KNIME community,

Problem #1: Most probably, there is no need of a loop for the manipulation you want to do, but without a data example, snapshot, or workflow uploaded here, it is difficult to know what you have implemented.

Problem #2: In a -rue-engine- node, it is most often needed to add a last rule stating what to do when any of the previous rules didn’t succeed. For instance:

$column$ = "Hello" => "Hello my friend'
$column$ LIKE "Hello*" => "Hello, how are you?"
TRUE => "$column$

If I do not add the TRUE => "$column$, any cell in $column$ not containing the word “Hello” would become empty and hence appearing tagged as a Missing Value. That’s why most often a TRUE => "Something here for the last default option" is needed.

Please share your workflow here or at least a bit of your data in text format with a snapshot example to helping you further.

Hope it helps.

Best

Ael

4 Likes

Thanks for the reply, now I understand the issue related to problem#2.

Here is the screenshot for the problem#1, kindly note that workflow is working fine but it creates copies of data in main excel file. I think it appends the data after each iteration. While it should overwrite the data based on the event-table. ( I tried variable condition loop end, it had the option to provide the data of last iteration only, but it had to be provided the exact number of iteration number, which I want to automate, it should be equal to the number of rows in event table )

Thanks for posting an snapshot of your workflow. A Loop End node always appends all the rows of each iteration to the final table. Thus, if for instance you iterate N times over a same table as it is here the case with your loop configuration, then you should have N x times the number of rows present in your Excel table.

Would it be possible for you to upload here your workflow already run (even if the results are wrong) so that we can help you from there ? It would be much easier and faster for us to eventually help you.

Best

Ael

PS: For correctness, I post again here my previous dummy example because it had misspellings:

$column$ = "Hello" => "Hello my friend"
$column$ LIKE "Hello*" => "Hello, how are you?"
TRUE => $column$

Avoiding Loops would probably be the best option but if your performance is fine and you only want the last iterration you should be able to check the iteration number in loop end and then filter to the last one to get rid of the other data. If your data requires working with intermediate results you should check recursive loops (if you really need a loop)
br

Thank you for replying, now I understand that loop-end node appends the rows of each iteration. I have sorted the problem by applying row-filter + duplicate filter nodes, results were already fine, no issues with them.

My concern was that why rows were appending (you have clarified it, thanks) and how to prevent the appending rows (I found variable condition loop end node which has the option to get the last iterated rows only).

Could you suggest some solution without loops to implement this workflow (workflow attached in the comments.).

Again thanks.

Thank you for replying,

Yes you are right, i want to avoid the loops as I might have to work with the big-data where it would not be possible to append all the rows after each iteration.

Could you suggest some solution without loops (Image uploaded above). Thanks.

Hi @nikola_tesla

After analysing your workflow, I have the impression that your question (need) is very similar to the one in the following post, where I already provided a solution:

In your Table creator you have "Starting Dates + “Ending Dates” + “Event Numbers”. You need to know if the Time event is between the beginning & ending dates just for a precise given event.
This is what the workflow here above is doing with very similar data.

As explained in the above linked thread, the -Group Start- loop nodes are not needed in theory and the job could be done without. However, they will help if the # of rows in your Excel file is huge. If it is not, you could remove the two loop nodes and still the workflow should work.

Hope this workflow and complementary comments help to solve your problem.

Best

Ael

2 Likes

Thank you for your responses, now I have understood it. Thanks again. :slight_smile:

1 Like

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