# Editing a Single Column using LINQ

**URL:** <https://forum.uipath.com/t/editing-a-single-column-using-linq/369382>\
**Category:** Community\
**Tags:** community, question, forum, system, activities\
**Created:** [December 13, 2021, 2:05pm UTC](https://forum.uipath.com/t/editing-a-single-column-using-linq/369382 "2021-12-13T14:05:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashwin.ashok](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ashwin.ashok/32/300916_2.png) [@ashwin.ashok](https://forum.uipath.com/u/ashwin.ashok)\
**Post date:** [December 13, 2021, 2:05pm UTC](https://forum.uipath.com/t/editing-a-single-column-using-linq/369382/1 "2021-12-13T14:05:53Z")

</div>

I have a datatable which looks like this:

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

Id like to remove all the special characters other than digits from the **Phone No.** column. I know this can be achieved using a **For Each** , but I wanted to know whether it was possible using **LINQ**.

ALSO

The columns are **dynamic** i.e, we might not always know what all columns might be added, as I am joining several tables together.

Help would be most appreciated, thanks in advance!

**Kind Regards,  
Ashwin A.K**

---

<div class="post-metadata">

**Author:** ![postwick](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/postwick/32/227083_2.png) [@postwick](https://forum.uipath.com/u/postwick)\
**Post date:** [December 13, 2021, 2:07pm UTC](https://forum.uipath.com/t/editing-a-single-column-using-linq/369382/2 "2021-12-13T14:07:00Z")

</div>

Just use a For Each. This obsession around here with avoiding For Each is pointless. It’s not a performance issue. LINQ loops anyway, it’s just hidden to you.

---

<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:** [December 13, 2021, 2:12pm UTC](https://forum.uipath.com/t/editing-a-single-column-using-linq/369382/3 "2021-12-13T14:12:29Z")

</div>

in case of only a few columns are to update go for a for each  
we can do it with a `regex.replace(YourString, "\D", "")`

In case of the column name / index is unclear we can iterate over the ItemArray and check if its needed (also can exclude columns within the same time)

Doing it consequently on all columns:

> [@LINQ query to update(replace)datatable in uipath](https://forum.uipath.com/t/linq-query-to-update-replace-datatable-in-uipath/174612/8):
>
> @Rachel7 this is maybe a too quick shot as it replace any space in any column to NA and returns a datatable. But you can give a try (From r In dtData.AsEnumerable Select ia = r.ItemArray.toList Select ic = ia.ConvertAll(Function (e) e.ToString.Trim.Replace(" ","NA")).toArray() Select dtCorrected.Rows.Add(ic)).CopyToDataTable() NEW VERSION, simplified: (From r In dtData.AsEnumerable let ra = r.ItemArray.Select(Function (x) x.ToString.Trim.Replace(" ","NA")).toArray() Select dtCorrected.Rows.…

Also have a look here:  
[How to Update Data Column Values of a Data Table | Community Blog](https://www.uipath.com/community/rpa-community-blog/options-for-updating-data-table-column-values)

---

<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:** [December 16, 2021, 2:13pm UTC](https://forum.uipath.com/t/editing-a-single-column-using-linq/369382/4 "2021-12-16T14:13:19Z")

</div>

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