# Spliting datatables

**URL:** <https://forum.uipath.com/t/spliting-datatables/526405>\
**Category:** Activities\
**Tags:** datatable, studio, activities, excel\
**Created:** [March 15, 2023, 4:13pm UTC](https://forum.uipath.com/t/spliting-datatables/526405 "2023-03-15T16:13:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Md\_Hidayat](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/md_hidayat/32/253327_2.png) [@Md\_Hidayat](https://forum.uipath.com/u/Md_Hidayat)\
**Post date:** [March 15, 2023, 4:13pm UTC](https://forum.uipath.com/t/spliting-datatables/526405/1 "2023-03-15T16:13:55Z")

</div>

Hi all,

Is there a way to split this excel into 3 seperate datatables?  
The final output will be in step 4, which is to get 3 datatables.

1. Read Range as dtAll in Test Sheet
2. Count the number of Row.
3. Get total rows in dt divide by 3
4. Create 3 new datatables base on result in 3.  
a. dt1 = row2 - 61  
b. dt2 = row 62 - 121  
c. dt3 = 122 to last row.

[TestFile.xlsx](https://forum.uipath.com/uploads/short-url/nbc6zJSUDALSU1AtOWGFcKk8LHY.xlsx) (43.2 KB)

Thanks for helping out in advance!

Regards  
Hidayat

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [March 15, 2023, 4:20pm UTC](https://forum.uipath.com/t/spliting-datatables/526405/2 "2023-03-15T16:20:09Z")

</div>

> [@Process repeated for each multiple rows](https://forum.uipath.com/t/process-repeated-for-each-multiple-rows/232282/4):
>
> @christine.tzenghy let me introduce a general approach that can be also adopted to more case specific details. Assumptons: DataTable with 8 Rows Segmentsize: 3 Following Building Blocks are used Calculation of the numbers of segments: [grafik] with the Ceiling method the fractions are uprounded to the next Integer with the Skip() and Take() Method the Rows for a segment can be retrieved. the different segments are bult by following [grafik] and do fetch the different segment rows by: …

---

<div class="post-metadata">

**Author:** ![NIVED\_NAMBIAR](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nived_nambiar/32/169066_2.png) [@NIVED\_NAMBIAR](https://forum.uipath.com/u/NIVED_NAMBIAR)\
**Post date:** [March 15, 2023, 4:20pm UTC](https://forum.uipath.com/t/spliting-datatables/526405/3 "2023-03-15T16:20:14Z")

</div>

Hi @Md_Hidayat

try this

1. Read excel file and store in datatable
2. Assign a int32 variable a = 60
3. Use the while loop as below condition  
a\<dt1.Rows.Count  
Inside the loop do the following  
a. dt\_temp = dt1.AsEnumerable().Skip(a).Take(60).CopyToDataTable  
b. Write dt\_temp into excel file  
c. Increment a= a+60

Let me know if it works

Thanks & Regards,  
Nived N

---

<div class="post-metadata">

**Author:** ![Md\_Hidayat](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/md_hidayat/32/253327_2.png) [@Md\_Hidayat](https://forum.uipath.com/u/Md_Hidayat)\
**Post date:** [March 15, 2023, 5:00pm UTC](https://forum.uipath.com/t/spliting-datatables/526405/4 "2023-03-15T17:00:40Z")

</div>

Thanks for the quick reply!

I tried your method. Is it possible to save the into 3 datatables to enable parallel processing?

 ![Capture](https://global.discourse-cdn.com/uipath/original/4X/3/3/9/3397cca8a84651f599a383ad227ee84da2e72cbb.jpeg)

Regards  
Hidayat

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [March 15, 2023, 5:37pm UTC](https://forum.uipath.com/t/spliting-datatables/526405/5 "2023-03-15T17:37:59Z")

</div>

Yes,maybe need some little adaptions. But the building Blocks and the main Idea would be the same

---

<div class="post-metadata">

**Author:** ![Md\_Hidayat](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/md_hidayat/32/253327_2.png) [@Md\_Hidayat](https://forum.uipath.com/u/Md_Hidayat)\
**Post date:** [March 15, 2023, 5:50pm UTC](https://forum.uipath.com/t/spliting-datatables/526405/6 "2023-03-15T17:50:34Z")

</div>

Thanks @ppr and @NIVED_NAMBIAR for pointing the correct direction.

I’m able to mix and match both of you guys solutions. 😃

Regards  
Hidayat

---

<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:** [March 18, 2023, 5:51pm UTC](https://forum.uipath.com/t/spliting-datatables/526405/7 "2023-03-18T17:51:14Z")

</div>

Closed on March 18, 2023, 5:51pm UTC

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