Using Loop
I am unable to get loop to work with me, maybe you can tell me how I can work better with loop. In the process below I am reading from a SQL server to enrich data. I need to limit the number of lines selected in the extract to 1, this bit I am getting correct, also I am correctly selecting the second row of data when I manually loop the process.
I have tried numerous loop operators but none of them play along. I need to loop the below process based on the number of entries that there are in a sql table. I need to select one line at a time, run the process and then loop it. Help!
Best Answer
-
robin Member Posts: 100 Guru
Thank you, sent me in the correct direction. Perviois experience with loops was clouding my understanding.
Did not realise that I had to place the process inside the loop operator, once I figured that it was all good.
0
Answers
The screenshot isn't that helpful for understanding what you are actually trying to do. You should paste the XML of your process instead. Also, you mentioned you can get your loop to read the db table one line at a time, so can you be more descriptive about what else you want it to do and where it is failing? The process based on the picture is quite long so it would take another community memeber a while to try to figure it all out for troubleshooting.
Lindon Ventures
Data Science Consulting from Certified RapidMiner Experts
The problem is more understanding which loop opperator to use and where to place it. There are a number of loop operators, however which one should I be using to extract a single entry from a MySQL database? When I run the process, as the data inside the database is enriched with information it is removed from the table that I cam calling from and placed on another table. The process I am running can only handle one entry at a time, which is why I need to take this approach.
Secondly where does one place the loop, when coding a loop it normally goes at the end of a process, however from the various tutorials I have watched as well as sample processes I have used it seems to be in different locations. What determines where it should be placed?
I will attempt to create a sample process and post here to aid the discussion.
Hi Robin,
your xml code always seems to be corrupted, as it includes several <process></process> tags, which would indicate several processes. The easiest way to correctly copy the xml code is to go to the xml tab, click the right mouse button and chose "Select All" in the drop-down. Then just copy it and paste it into the community forum within code tags.
Having said all that, I think what you could try to do, in order to solve your processing problem, is to work with the "Loop Examples" operator in combination with the "Extract Macro". Instead of manually entering the row number in the "Extract Macro" operator, you could just enter a macro with %{MACRO_NAME} for the example index. This would be the same name that you gave the iteration macro in the "Loop Examples" operator. The "Extract Macro" operator and anything that you would want to do with the respective selected database output row needs to be nested within the "Loop Examples" operator.
Without having access to your correct XML code, it's difficult to be more specific. But the explanation above should give you an idea of how you can go about it.