# DATATABLE Split into Chunks

**URL:** <https://forum.uipath.com/t/datatable-split-into-chunks/539697>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, activities, excel, system\
**Created:** [April 27, 2023, 9:41am UTC](https://forum.uipath.com/t/datatable-split-into-chunks/539697 "2023-04-27T09:41:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishal\_nachankar](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@vishal\_nachankar](https://forum.uipath.com/u/vishal_nachankar)\
**Post date:** [April 27, 2023, 9:41am UTC](https://forum.uipath.com/t/datatable-split-into-chunks/539697/1 "2023-04-27T09:41:14Z")

</div>

Hi I have a datatable with lakhs of rows into it . now i want to Spit the datatable into chunks of 30000 and add it to the excel file .. How can i acheive this

---

<div class="post-metadata">

**Author:** ![arjunshenoy](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/arjunshenoy/32/404588_2.png) [@arjunshenoy](https://forum.uipath.com/u/arjunshenoy)\
**Post date:** [April 27, 2023, 9:43am UTC](https://forum.uipath.com/t/datatable-split-into-chunks/539697/2 "2023-04-27T09:43:17Z")

</div>

Hi @vishal_nachankar

Please look into the following thread:

> [@Split Datatable into 4 different tables](https://forum.uipath.com/t/split-datatable-into-4-different-tables/284608):
>
> Hey guys, So i generate a datatable with 100+ rows every week. Now i’d like to split that table into 4 parts with about equal numbers of rows in each. Found some rather complicated solutions but is there a simple way to do this? And also a random question: What would be the best language to learn to improve in UIpath? C#? Thanks,

Best Regards.

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [April 27, 2023, 9:43am UTC](https://forum.uipath.com/t/datatable-split-into-chunks/539697/3 "2023-04-27T09:43:56Z")

</div>

@vishal_nachankar

Please check this

> [@Insert data in queue with Bulk add Queue items error](https://forum.uipath.com/t/insert-data-in-queue-with-bulk-add-queue-items-error/531589/3):
>
> @Deep_HML To confirm…did you try with only onw row of data? …first try with it…it might be that the columns names are not exactly matching or so…check those… And yes the limit is 15k or so… We can break the table into rows of 10k and add in 3 loops So use for loop with Enumerable.Range(0,Cint(Math.Ceiling(dt.RowCount/10000))).ToArray and change type argument to integer And inside loop to get each chunk use dt.AsEnumerable.Skip(currentitem\*10000).Take(10000).CopyToDataTable And use the chun…

Cheers

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [April 27, 2023, 9:50am UTC](https://forum.uipath.com/t/datatable-split-into-chunks/539697/4 "2023-04-27T09:50:14Z")

</div>

Hi,

Hope the following sample helps you.

 ![image](https://global.discourse-cdn.com/uipath/original/4X/2/4/3/243b4fd71ed6ad6931453bd12fd6e1a1a3cad012.png)

```
arrDt = Enumerable.Range(0,(dt.Rows.Count \ chunkSize)-CInt(dt.Rows.Count mod chunkSize >0)).Select(Function(i) dt.AsEnumerable.Skip(i*chunkSize).Take(ChunkSize).CopyToDataTable).ToArray

```

[Sample20230427-5L.zip](https://forum.uipath.com/uploads/short-url/fiD7HDDyzjwifs2alRRU6P0GdTh.zip) (8.6 KB)

Regards,

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [April 30, 2023, 9:50am UTC](https://forum.uipath.com/t/datatable-split-into-chunks/539697/5 "2023-04-30T09:50:48Z")

</div>

Closed on April 30, 2023, 9:50am UTC

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