# Structure of Loops

Hi,

I need to insert data FROM an Excel onto a website. In one part I need to fill ALL the data of a particular row if the Account = 0kg. If not I ONLY need to fill in the data of 2 particular columns(Column1 and Column2) of the NEXT row and check again if Account = 0kg. Below are the steps:

1. Type Row(1) of DataTable(From excel to Website)

2. Check if Account = 0kg: (On website(UI Element))

3. If YES: Click “Close” → Type Into Row(2) of DataTable(From excel to Website)

4. If NO: Type into Row(2)(“Column 1”) AND Type into Row(2)(“Column 2”)

5. Check if Account = 0kg:

6. If YES: Click “Close” → Type Into Row(3) of DataTable(From excel to Website)

7. If N0: Type into Row(3)(“Column 1”) AND Type into Row(3)(“Column 2”)

Can someone please tell me how can I do this?
Should I use a For loop, a While loop, a While Do Loop, …

I used a for loop inside a for loop but I think everything is going berserk!

How do I update the Row number? For ex: Row(1), Row(2), Row(3)…
How can we update a row with a counter?

Thanks!

you have to take data from the excel or website where the account =0 is in excel row or in web and what you want to fill in the column1 and column2 can you please tell

Thanks
Chethan P

When I put the data from Excel into the Website, I need to click on a button and then it will tell me the Account if 0 or not.

And if the account is not 0kg then I need to take the value of column1 and column2 in the Excel of the NEXT row and insert it again on the website and check if account has become 0kg.

1 Like

It was simple you just do like what you said to use if condition if ur using get text data the value becomes zero the then row.item(“Column2”).tostring or use row(1).tosting hear 1 is the column you need to increment it means put assign if it 0kg then increment the assign variable use plus 1 like this you can loop

if you not get please send one sample excel file

Thanks
Chethan P

Batch_Data_ASOS_June.xlsx (38.9 KB)

1 Like

I believe you should be able to solve it with a For Each Row loop and two boolean variables: isZeroKG and isFirstIteration

Pseudocode:

``````isZeroKG = True
isFirstIteration = True

For Each Row r in DT
If (isZeroKG) Then
If (isFirstIteration) Then
isFirstIteration = False
Else
Click "Close"
End If

Type Into r
Else
Type Into r("Column 1") and r("Column 2")
End If

isZeroKG = Account.Equals("0kg:")
Next r
``````
2 Likes

can you please explain in the uipath format?

Thanks
Chethan P

1 Like

Testing.xaml (16.6 KB) temparature.xlsx (8.3 KB)

buddy i did what yo said it will compare the data using if condition

its not like your project it was related hear am compare the temp. if column 1 is not match it will go to column 2 like this

if get the solution inform me

Thanks
Chethan P

The basic idea is that any iteration after the first is the same (but with a different row). If you look closely at the first iteration, it’s just the YES path without the Click “Close” activity. That is why we set isZeroKG to true and skip Click “Close” in the first iteration.

The rest of the pseudocode is basically in UiPath format. A few Assign activities, one For Each Row activity, two If activities and a few Type Into activities.

yes I did the same thing but I have a question if we have 20 column is there on that time what we have to do code performance is slow right

Thanks
Chethan P

20 columns don’t sound much so it’s weird that it would affect the performance. Have you been able to pinpoint the bottleneck?

Hi @Yudhisteer_Chintaram1
Have a look at that workflow
Main.xaml (14.0 KB)

You can look at the workflow comments which i had put to get the logic how we can execute the workflow

I am preffering a while loop here to do the process

@copy_writes please have a look on that too

Regards,
Nived N
Happy Automation

2 Likes

Can you please check and review my code I need to know what i did if yo dont mine

there is some issue with the package

when i open ur xaml file @copy_writes

1 Like

Batch_Bot (2).pdf (1.1 MB)

@NIVED_NAMBIAR @copy_writes @ptrobot Here’s the screenshots of the process flow.
Maybe you will get a better idea with this.

Yes I got these issues too.

WelCome_mail in ChatBot.zip (22.0 KB)

did u tried the concept which i had sent ?

What is data_1 and data_2 please?

Can you explain me this step too please?