Iterate excel range for every 100 data upload

Hi ,

I have an excel with 4L data, i want to upload in DB which is allowed only 100 per upload,
I have developed a project based on my knowlegde, where i have provided the range as static for the first upload, but for future upload the range should be dynamic so that i can upload all the data.

Attached the Xaml for reference.
Main.xaml (11.8 KB)

Thanks in advance.

Hello @Mohamed_Ameer1

You can use a counter of use skip and Take function in a LINQ query and you can get the batch by batch 100 records.
skipCounter=0

.Skip(skipCounter).Take(100);`
SkipCounter= SkipCounter+100

Thanks

Happy Automation!

We assume that the project is set to Windows Compatibility

Assign Activity:
TableList | DataType_ List(Of DataTable) =
yourDataTableVar.asEnumerable().Chunk(100).Select(Function (x) x.CopyToDataTable).toList

We get returned a List of DataTables, where each datatable is representing a segment of 100 rows

Hi @Mohamed_Ameer1

=> Read Range Workbook
Output-> dt

=> Use the below condition in Assign:
List_Dt = dt.AsEnumerable.Chunk(100).Select(Function(a) a.CopyToDataTable).ToList

List_Dt is of DataType System.Collections.Generic.List(System.Data.DataTable)

=> You can use For Each loop to iterate through List_Dt and push it to Database.

Hope it helps!!

In older times, before the Chunk operator was introduced, we used Skip / take and did it in this way

Hi @adiijaiin @ppr @Parvathy thanks for your quick response.

I would like to go with the below method, but i am getting an error:

It is better if i have the flow as i am a learner and much appreciated!

Ensure that the variable Datatype is set to a list (of DataTable)

yes, it is :slight_smile:

Note: i have two excel one is input where i have the 4L data, and output to iterate every 100 records as i dont want to modify the input sheet.

Hi @Mohamed_Ameer1

Go to Browse For Types type System.Collections.Generic.List you will find List . In place of T pass System.Data.DataTable.

Check the below image for better understanding:

Regards

no, as this is needed:
grafik

1 Like

Hi @Parvathy ,

I am again struck here

Hi @Mohamed_Ameer1

Use For Each loop. Below image will give you a better understanding of the flow. If you are going to write the data to excel then please initialize Counter to 1 . Inside the For Each loop after Write Range Workbook increment the counter by 1.

Check the below image

Regards

We recommend to have a complete understanding of what is modelled

Minisample
grafik

DataTable is segmented within a size of two DataRows.
Within the TableList we do have the splits as segmented DataTables

Therefore we use the For Each Activity for the loop and can process the iterated DataTable

About LINQ:
[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum

Thank You, it worked but it is also creating empty space in the excel which causes upload failure in DB as it doest not accept space as values.But actual datas are in A and B column only, Could help in figuring out.

Nice, Thank you!

Now I understand the architecture clearly.

Perfect, as with the very early given approach of chunk(X)

now we can check for cleansings

just share some samples from the

  • input data
  • the resultinh output data

along with the elaboration on what is needed, what is to cleanse in which way

@Parvathy Now i got the point, if the input data is less than 100 then it makes empty space untill the loop exist!

Thanks for your help!!

cannot confirm as we can see:
grafik

it is not filled up to the segment size.

Maybe we do misunderstand your statement and you can elaborate more on this

I can understand the situation now, after successfull update in DB i am deleting the data to get the next batch, please refer below screenshot and let me is there any alternate way to handle this?

please support us on this, then we can check for the fitting options

We do not see so far the need for cleansings, as the data can be used directly