How to replace a value in datatable in Uipath without using for each row

How to replace a value in datatable in Uipath without using for each row

Hi @Rachel7

You want to find and replace all the match of the value or a specific column?


If you know the column and row of the value you want to replace, you can call it through DT.Rows(“row”).Item(“column”) and use an assign activity to set it as you like.

Set “row” to the row in the table
Set “column” to the column in the table

1 Like


Have you tried Lookup Data Table. You can search DataTable without using For Each Row and you will get the RowIndex for a particular value and then replace the cell value with the index.

Welcome back to uipath community
There are actually two ways of doing that
—first is convert the datatable to a string with the help of OUTPUT DATATABLE ACTIVITY and pass the datatable as input and get the output variable of type string named str_output
—now use a normal assign activity like this
str_output = str_output.ToString.Replace(“your old value”,” your new value”)

Now use GENERATE DATATABLE ACTIVITY and mention the str_output variable as input
And get the output with a variable of type datatable named Finaldt


Use a assign activity like this if we know which column values we want to replace
dt = dt.AsEnumerable().Where(Function(a) a.Field(of string)(“yourcolumnname”).ToString.Replace(“your old value”,” your new value”).ToString).CopyToDatatable()

Cheers @Rachel7


With LINQ query to update(replace)datatable in uipath

Similiar question was resolved. Can you please give Feedback If this topic ist still Open. Thanks

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