KAPOW

Would you like to react to this message? Create an account in a few clicks or log in to continue.
KAPOW

Welcome to the Kapow forum. Here you can get help, use your skills to help others and enjoy hanging out in the company of other Kapow Robot Developers.


2 posters

    Double Loop on one path

    avatar
    andobe


    Posts : 14
    Points : 1901
    Join date : 2019-03-22

    Double Loop on one path Empty Double Loop on one path

    Post by andobe Thu Apr 18, 2019 6:04 pm

    Hi again.

    So i have had a question for a long time. Is it possible to have two loops on one path? 
    Like on the attached image, i Extract data from XML and the insert it into an Excel file, but right now it just replace the data in excel.
    So how can i insert the data into a new row with each extraction iteration from the XML?
    batman
    batman


    Posts : 47
    Points : 1923
    Join date : 2019-03-19

    Double Loop on one path Empty Re: Double Loop on one path

    Post by batman Thu Apr 18, 2019 7:46 pm

    You can have two or more loops on the same path e.g. where you want to loop through rows and columns in a Spreadsheet. But you have to remember that everything after the loop will run to completion before it starts the next iteration, including subsequent loops and branches.

    If you're trying to loop through XML content and then dump it into Excel then you probably just need to adjust the finders for your Excel Set Content steps so they work dynamically rather that using absolute references to a cell.

    Screenshot below shows a similar type of process that just loops through a CSV and copies the content into Excel.

    Double Loop on one path Csv_to10

    In the configuration of the Set Content step it uses an expression to define which cell to place the result. It uses the current iteration of the CSV loop to locate the row in the spreadsheet but if your rows numbers don't match exactly you can adjust this to handle any skipped rows etc.

    Double Loop on one path Set_co11

    No second loop needed in this case
    avatar
    andobe


    Posts : 14
    Points : 1901
    Join date : 2019-03-22

    Double Loop on one path Empty Re: Double Loop on one path

    Post by andobe Thu Apr 18, 2019 8:24 pm

    Alright, awesome, but i need it to start setting content from row 4 how do i put in that condition?
    batman
    batman


    Posts : 47
    Points : 1923
    Join date : 2019-03-19

    Double Loop on one path Empty Re: Double Loop on one path

    Post by batman Thu Apr 18, 2019 8:28 pm

    Just add 4 to the iteration from your XML loop

    e.g. "Sheet!A" + (iteration() + 4)

    avatar
    andobe


    Posts : 14
    Points : 1901
    Join date : 2019-03-22

    Double Loop on one path Empty Re: Double Loop on one path

    Post by andobe Thu Apr 18, 2019 8:33 pm

    Yeap got it! 

    Last question, the row contents get inserted but with the next iteration, the information disappears from the previous row. how come is that?
    batman
    batman


    Posts : 47
    Points : 1923
    Join date : 2019-03-19

    Double Loop on one path Empty Re: Double Loop on one path

    Post by batman Thu Apr 18, 2019 8:41 pm

    You'll need to set your Excel variable as a Global variable.

    Double Loop on one path Excel_10

    Variables get reset on each iteration of the loop, so if you want to maintain state just check the box

    Sponsored content


    Double Loop on one path Empty Re: Double Loop on one path

    Post by Sponsored content


      Current date/time is Sun Apr 28, 2024 2:04 pm