# Split coulmn on data table based on ","

**URL:** <https://forum.uipath.com/t/split-coulmn-on-data-table-based-on/725533>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, excel, activities\
**Created:** [2024 年 3 月 9 日午後 2:51 UTC](https://forum.uipath.com/t/split-coulmn-on-data-table-based-on/725533 "2024-03-09T14:51:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrian\_sullivan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/adrian_sullivan/32/271663_2.png) [@adrian\_sullivan](https://forum.uipath.com/u/adrian_sullivan)\
**Post date:** [2024 年 3 月 9 日午後 2:51 UTC](https://forum.uipath.com/t/split-coulmn-on-data-table-based-on/725533/1 "2024-03-09T14:51:51Z")

</div>

hi all,

i have an excel sheet.

 ![image](https://global.discourse-cdn.com/uipath/original/4X/b/4/6/b46089813a3e9ec376889575f88d28169300f852.png)

i have read it into a datatable  
what i need to do is to get the everything in to one column. the rows with a comma should be split and the data after the column added to the datatable

it should look like this. (the order does not matter to me)

 ![image](https://global.discourse-cdn.com/uipath/original/4X/e/4/e/e4e1c15d03290065531a1452516007cfdac8b039.png)

any suggestions

thanks,  
[Split dataTable.xlsx](https://forum.uipath.com/uploads/short-url/dRHJl8URJbm1EGocQEZHAp6O85v.xlsx) (11.0 KB)

---

<div class="post-metadata">

**Author:** ![vrdabberu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vrdabberu/32/484365_2.png) [@vrdabberu](https://forum.uipath.com/u/vrdabberu)\
**Post date:** [2024 年 3 月 9 日午後 3:08 UTC](https://forum.uipath.com/t/split-coulmn-on-data-table-based-on/725533/2 "2024-03-09T15:08:16Z")

</div>

Hi @adrian_sullivan

=\> Read Range Workbook  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/2/6/5/26559113546a4f8f22a358eb2498c53278041ef2.png)  
Output-\> dt

=\> Use below syntax in Assign:

```auto
dt = (From row In dt.AsEnumerable()
            From column In row.Field(Of String)("Column").Split(","c)
            Select dt.Clone().Rows.Add(column)).CopyToDataTable()

```

=\> Write Range Workbook `dt`  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/7/0/e/70eb025a797039be225f8c316cca7504b303afc7.png)

 ![image](https://global.discourse-cdn.com/uipath/original/4X/f/6/d/f6dd8138f350190bd8d3c46ed276dda2eeef0bbd.png)

Regards

---

<div class="post-metadata">

**Author:** ![Jayesh\_678](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jayesh_678/32/219158_2.png) [@Jayesh\_678](https://forum.uipath.com/u/Jayesh_678)\
**Post date:** [2024 年 3 月 9 日午後 3:21 UTC](https://forum.uipath.com/t/split-coulmn-on-data-table-based-on/725533/3 "2024-03-09T15:21:03Z")

</div>

Hi,

Here I used input:-

 ![image](https://global.discourse-cdn.com/uipath/original/4X/2/5/d/25d0813be347e6b76ab59b77f4bb964ec3842907.png)

Output:-  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/1/9/a/19a6a68f2586454743bb19f9425603cb8ab28bd3.png)

Please find attached workflow for your ref.  
[Split datatable column.zip](https://forum.uipath.com/uploads/short-url/nmL41nvICiaN2VryrPJoi8SdvCL.zip) (3.6 KB)

If this works for you, please mark this as a solution, so others can refer this. 🙂

---

<div class="post-metadata">

**Author:** ![adrian\_sullivan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/adrian_sullivan/32/271663_2.png) [@adrian\_sullivan](https://forum.uipath.com/u/adrian_sullivan)\
**Post date:** [2024 年 3 月 9 日午後 3:22 UTC](https://forum.uipath.com/t/split-coulmn-on-data-table-based-on/725533/4 "2024-03-09T15:22:04Z")

</div>

That is great, working for me.

i was trying to use an if statement and go from there but your solution is much better.

thanks,  
Adrian

---

<div class="post-metadata">

**Author:** ![adrian\_sullivan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/adrian_sullivan/32/271663_2.png) [@adrian\_sullivan](https://forum.uipath.com/u/adrian_sullivan)\
**Post date:** [2024 年 3 月 9 日午後 4:12 UTC](https://forum.uipath.com/t/split-coulmn-on-data-table-based-on/725533/5 "2024-03-09T16:12:17Z")

</div>

back again, found in my data a very large number. this causes an error when using the assign activity

 ![image](https://global.discourse-cdn.com/uipath/original/4X/8/7/6/876603fea94464ac7af79a62e3b0499e4198026e.png)

[Split dataTable.xlsx](https://forum.uipath.com/uploads/short-url/xnfP9guoUdekMdetNS0kn3dz1Qr.xlsx) (11.0 KB)

any suggestions to get aroung this issue

thanks again

---

<div class="post-metadata">

**Author:** ![vrdabberu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vrdabberu/32/484365_2.png) [@vrdabberu](https://forum.uipath.com/u/vrdabberu)\
**Post date:** [2024 年 3 月 9 日午後 4:17 UTC](https://forum.uipath.com/t/split-coulmn-on-data-table-based-on/725533/6 "2024-03-09T16:17:36Z")

</div>

Hi @adrian_sullivan

Try this syntax:

```auto
dt = (From row In dt.AsEnumerable()
            From column In row.Field(Of Object)("Column").ToString().Split(","c)
            Select dt.Clone().Rows.Add(column.Trim())).CopyToDataTable()

```

**Input**  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/2/4/4/244f2a00c2a87f3745c89828dc58ef19414e8f8f.png)

**Output**  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/a/0/d/a0d7eba2458b98a8156d1a445e87c4a73f97d793.png)

Regards

---

<div class="post-metadata">

**Author:** ![adrian\_sullivan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/adrian_sullivan/32/271663_2.png) [@adrian\_sullivan](https://forum.uipath.com/u/adrian_sullivan)\
**Post date:** [2024 年 3 月 9 日午後 4:26 UTC](https://forum.uipath.com/t/split-coulmn-on-data-table-based-on/725533/7 "2024-03-09T16:26:00Z")

</div>

perfect that worked just fine

thanks

off to watch some rugby now

---

<div class="post-metadata">

**Author:** ![adrian\_sullivan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/adrian_sullivan/32/271663_2.png) [@adrian\_sullivan](https://forum.uipath.com/u/adrian_sullivan)\
**Post date:** [2024 年 3 月 11 日午後 4:37 UTC](https://forum.uipath.com/t/split-coulmn-on-data-table-based-on/725533/8 "2024-03-11T16:37:51Z")

</div>

so i am back with another compliaction to this query

[Split dataTable.xlsx](https://forum.uipath.com/uploads/short-url/5P0dkNdkQ4iS7eBFDrGDkh5FtLP.xlsx) (11.3 KB)  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/f/6/b/f6b9bafced7abdf14b7060ebdab40534df2d373f.png)

i discovered that if i split coulmn3 out then i run into problems later with a join that i have for another data table.

so i will have from this data table abc,def, then from another data table abc and def and when i go to join them together they will not match up. is there anyway of getting my datatable to look like this

![image](https://global.discourse-cdn.com/uipath/original/4X/d/0/c/d0c1019cdf8fe874dbfe3a4543bb34e414c2a13b.png)

so i need to split the column based on the “,”  
then add a new row with all the original data except for what is before the “,”

thanks

ps rugby did not go as planned…

---

<div class="post-metadata">

**Author:** ![vrdabberu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vrdabberu/32/484365_2.png) [@vrdabberu](https://forum.uipath.com/u/vrdabberu)\
**Post date:** [2024 年 3 月 11 日午後 4:49 UTC](https://forum.uipath.com/t/split-coulmn-on-data-table-based-on/725533/9 "2024-03-11T16:49:30Z")

</div>

Hi @adrian_sullivan

Can you raise a new query regarding this, I will help you with solution.

Thanks in Advance  
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:** [2024 年 3 月 14 日午後 4:50 UTC](https://forum.uipath.com/t/split-coulmn-on-data-table-based-on/725533/10 "2024-03-14T16:50:26Z")

</div>

クローズされました: 2024 年 3 月 14 日午後 4:50 UTC

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