Hi all, I’m new to UiPath and was trying to do a simple automation flow. here’s a brief about it:
I’ve an excel sheet that contains 2 columns, I want to take batches of rows (10 rows at a time) and to be saved somewhere (maybe a variable) with comma separating them so i can execute a search on website. (this’s where I’m stuck)
and after that click some download button on that website and repeat until the file is over.
can someone please guide me how to execute the previous flow?
Use the “Excel Application Scope” activity to open the Excel file.
Inside the scope, use the “Read Range” activity to read the entire Excel sheet into a DataTable variable.
Batch Rows and Store in Variable:
Initialize an empty string variable (let’s call it batchRows).
Use a loop (e.g., “For Each Row”) to iterate through the DataTable.
Inside the loop, add each row’s value from the desired columns to the batchRows variable with a comma separator.
Keep a counter to track the number of rows added.
When the counter reaches 10, store the batchRows value in another variable (e.g., currentBatch), and reset batchRows for the next batch.
Continue this process until all rows are processed.
In this example, each batch of 10 rows is stored in the currentBatch variable as a comma-separated string. You can then use the currentBatch variable to execute searches on a website or perform other actions.
i think there’s still an issue with getting the batch of rows and assign it to the currentbatch
if you check these scr shots you’ll notice the counter is not getting reset and it keeps adding rows even if the batch contains 10 rows already
basically we are batching the data and creating a datatble if you need a column of chunks 10 as string we can do that as well into a string…Here dt is original data and dt1 inside loop is the chunks of 10
chunks - Enumerable.Range(0,Cint(Math.Ceiling(dt.RowCount/10))).ToArray
copy to table - dt.AsEnumerable.Skip(currentItem*10).Take(10).CopyToDataTable
Thank you for taking the time to solve my issue.
whenever I’m running this batches file i’m getting the following error:
For Each: Object reference not set to an instance of an object.