How to separate excel file if data have > 200 rows?

I want to check data if data have >200 row separate file

Example : I want file excel 441 Rows

I want output file_0 = data row 0-199 from original file
file_1 = data row 200-399 from original file
file_2 = data row 400-441 from original file

But if data <200 not change file

input.xlsx (11.8 KB)

output :
input_1.xlsx (9.3 KB)
input_2.xlsx (9.3 KB)
input_3.xlsx (7.9 KB)

Please guide me about it.

Hi!

First, you read your input file into a DataTable. Then you split it up into chunks with an Assign activity giving a second DataTable this value:

DemoDatatable.AsEnumerable().Skip(NumberOfItemsToSkip).Take(NumberOfItemsToTake).CopyToDataTable()

In your example NumberOfItemsToTake would be an integer of value 200. Your NumberOfItemsToSkip can be modified by a counter in a loop. Set the counter to 0 first and assign NumberOfItemsToSkip = counter * NumberOfItemsToTake. So on the first loop it skips 0, just gets the first 200, then skips 1 * 200, 2 * 200 and so on and so forth.

Happy Automating

@lukasziebold Please guide me for step or flow.
I’m newbie uipath.

Regards

As a newbie you should practice designing your solution yourself. Here are a couple more tips:

  • Find out how many output files you need by dividing YourDataTable.Rows.Count by NumberOfItemsToTake (200) - find out how to round up numbers in the forum
  • Use a While or Do While Loop and in the condition compare the number of needed output files with a counter (integer variable)
  • Follow my last response to split the DataTable and write the “current chunk” in an Excel file within the loop, so you get one file for each iteration
  • Of course at the end of the loop you need to set the counter = counter + 1

Practice makes perfect, happy automating

@lukasziebold Thank you for your guide.

I can do it.

Regard.

1 Like

As lukasiziebold commented, it is good for your practice to designing your sequence by yourself.
Here I attach sample process for helping your study.

1 Like

Thanks for the help, but your flow is confusing to me - why is it so cluttered? Simpler sample attached :wink:

1 Like

Charming flow !! Thanks

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.