Working with lines in a text file.

May 28, 2013 at 3:23 AM
Hi Guys,

I have run into a problem with an automation project I am currently working on.

My runbook starts off with a query to a database which works fine. I didnt not construct the SQL query, as this is not an area I am strong in so a lot of my work revolves around this already constructed query. Basically if the query returns any data, it is returned in lots of 5 rows. The easiest way I could think to work with this returned data is do write the results from the query into a text file, so ultimately I end up with a file that has multiple of 5 number of lines.

I have a child runbook that manipulates the data but I only want this to run once for each set of 5 rows. My problem is that I do not know how run the child runbook then delete the first 5 rows in the text file and then run the child runbook again...repeating this process until there is nothing left in the text file. At the moment, the basic structure of this child runbook is fine, it does what it should on the first 5 rows but as I said I do not know how to get it to run on the next 5 and then the next 5 etc...Can someone please help me out with this.

If you have any ideas on how this could be better achieved, I am all ears, I am still learning SCOrch and any advice is MUCH appreciated. If you have any questions, please ask, I feel like this is kind of hard to explain and I may be making little sense. :)
May 28, 2013 at 4:20 AM
Edited May 28, 2013 at 4:21 AM
OK so after a bit of experimentation, I went with putting a delete line activity toward the end of my child runbook, which deletes lines 1-5. I then have a Get Line activity which is set to read line 1-END (all lines). Finally, I have a return data activity that returns the published data from the Get Line activity which says how many lines were in the specified range (so this should be the number of lines left in the document right?)

My plan was to then invoke this child runbook from the parent runbook and get the invoke runbook object to loop with the exit condition being that the returned data (number of lines) = 0.

So this is all good IN THEORY. So i tried it out and I couldn't get invoke runbook to work..so i got rid of the looping, just to test if i could invoke the runbook at all...still nothing. There is clearly something wrong with how I am trying to use invoke runbook because it doesn't work at all. In the runbook tester, it tries 10 times before stopping but does not return any error messages so I don't know what to look for.