How to use foreach row within foreach row?

Iam try to read excel file based on row value of another excel file with in foreach row. How can i do?

3 Likes

Hi @Reshma

Can you please elaborate your scenario a little more. So I can come up with some solid solution.

What I understood from your question is, as you are using loop so you want to get each excel cell from your excel sheet. You’ll get new value after every iteration of loop. Right?

2 Likes

Hi @Muhammad_Hayyan Thank you for your response.

Iam trying to do one task the school info. Here i mention that link [School info task] (https://botsdna.com/school/)

  1. In this task, first I have to read [school code] one by one in excel file. So Iam using foreach row activity to get the school code.(i attached the screenshot)

2.Enter the school code and i click search button. It will show all school details in that website.

3.Then, I want to scrape all school details and write another one excel sheet.(i attached the screenshot)

  1. Then i want to read one by one data in the sheet2 data and write the data into excel sheet1 for fill all the data.

This is my task

My question is,
In step 1, Iam using foreach row activity to read sheet1 data. Next i want to read sheet2 data. How to read sheet2 Datas? and it is possible to do like nested foreach loop?

I tried to use foreach row activity to read sheet2 data but i cannot drag the foreach row activity within the sheet1 foreach row activity.So how to read the sheet2 file.

Can you say any alternative way to read the sheet2 data?

2 Likes

@Reshma You can use Do-while-loop activity inside the For each row Just drag and drop Do-while loop activity inside the For each row and modify the conditions and other activities inside loop.

2 Likes

Thank you @Kudlappa_Gouder :+1:

Hi @Reshma

Sorry for late response. Yesterday I was working on your project. I got the following solution. I hope it works for you and I hope this is what you wanted.
PS: It was fun and interesting working on this project.

I am attaching the following images for your ease and better understanding.

I created Google sheet file and saved the data in following way

This is the same google file but different sheet. It has the data what my Bot has scraped for me from the site you provided previously.

Here is the link of google sheet that I have used https://docs.google.com/spreadsheets/d/1HDCx0TFNmyrzAdv5MpNiZP-pBtvE9MRiWOrlh032JFg/edit#gid=0

Here I am attaching the file in zip form if you want to take help. In this case you just have to add the new codes in the google file.
School_Code_Practice.zip (1.1 MB)

Waiting for the feedback!

Kind Regards,
Muhammad Hayyan Khan

1 Like

Hi @Muhammad_Hayyan Thank you for your help :smile: :+1: You did this exercise in another one way. Its look good :smile: :+1:. I completed this exercise in another way using foreach row and do loop.

3 Likes

Hi @Reshma would mind sharing your solution here so that we can have a look.

2 Likes

Hi @spiderMonkey1 Here I attached my solution in zip file
Schoolinfo.zip (50.4 KB)

2 Likes