How to change data in one column in data table based on condition of another column


I have a data table which contains over 80,000 rows.
As part of my process I need to change data in a specific column that meet a condition in another column.
for example: if column I = “STR1” , replace Column N to “STR2” And if column I = “STR_5” , replace Column N to “STR_99”
and so on…

I can’t do it with For each activity because it is taking too long.
Is there any way performing it in another way?

I tried using Enumerable.Range:

Enumerable.Range(0,dt.AsEnumerable.Count).Where(Function(r) (dt.Rows(r).Item(“Column_I”).ToString=“STR1”).ToList

but it just return a list of row numbers and it doesn’t apply to the replace part…

Is there any other way?

What about making the datatable to string and use regex to find matches based on the condition you mentioned(“STR1” and column N= “STR2”) and replace it(to “STR3”)?

Do you mean by using output datatable activity?
and how can I convert it back to data table afterwards?

Sorre for late reply.

Output datatable → Regex → Generate datatable. I might be needed to create an example in the evening if you need it.

Hi @Metsada_semel

Welcome to UiPath forum.

Please find the below screen shot for your reference.


Note: CompareDT variable type should be Datatable.

Feel free to reach us at any time if you have doubts. Thanks.

Happy Automation

1 Like