Replace specific values(Nà) of all columns of datatable - Reopen

Hi All,

I want to replace value with blank one. I am able to replace other text values, since seems to be special symbol it is not getting replaced in data table.

Also if possible want to add multiple replace condition in same linq query.

Please refer below Linq which need to be modified.

(From r In dt_Final.AsEnumerable
Let ra = r.ItemArray.Select(Function (x) x.ToString.Trim.ToLower.Replace(“nà”,“”)).toArray()
Select dt_CSSorted.Rows.Add(ra)).CopyToDataTable()

@Palaniyappan @ppr @Yoichi



Is it possible to provide a sample file?


Hi @rishiathawale
How many row in your data?
If LinQ can not update, you can use activity for each row
assign value

Hi @Anil_G

This is how data table looks like. Where “Nà”, “NA” to be replaced by blank and “res” by “yes”


@Nguyen_Van_Luong1 datatable has dynamic and 1500+ rows hence trying to do it by linq.



do you mind sending a file…want to see how thye look in UiPath when read


@Anil_G Here it is.

New (13.6 KB)

Maybe Asc Code analysis can help:

@ppr Can you pls elaborate how can we achieve that?

Hi @rishiathawale ,

Could you let us know if you were receiving an Error when used the Above Code or was it not giving the Expected results ?


I am able to replace Nà now. but can you help using multiple replace condition in same linq. I am trying using OR condition, its throwing error.

@rishiathawale ,

We would require to know the conditions or Samples for deriving the logic.

This is how I am trying, error - does not allow to convert string to double.

If I remove OR condition it works well

@rishiathawale ,

I believe the Expression should be changed to the below :

(from r in dt.AsEnumerable
let ra = r.ItemArray.Select(Function(x) if(x.ToString.Trim.ToLower.Equals("nà"),"",If(x.ToString.Trim.ToLower.Equals("res"),"yes",x.ToString))).ToArray()
select dt_CSSorted.Rows.Add(ra)).CopyToDataTable

Also Interesting to know that the workflow shared was built in C# but a syntax is accepted.


What if I want to add more than 2 conditions? I see you have used nested IF.

Edited: Able to build the query for more that 2 conditions. Thanks

there will be a certain threshold where a resulting LINQ risks to get over-LINQed

One technique could be to work with a LookupDict

Assign Activity:
dictLK = new Dictionary(Of String, Object) From {{"res","yes"}, {"nà", ""}}

dtResult =

(From d In dtData.AsEnumerable
Let ra = d.ItemArray.Select(Function (x) If(dictLK.ContainsKey(x.ToString.Trim().toLower()),dictLK(x.ToString.Trim().toLower), x)).ToArray()
Select r= dtResult.Rows.Add(ra)).CopyToDataTable

Okay, I didnt face such issue yet, but yes due to over conditioned that might happen.

I will try LookupDict method. Thanks for pointing out.

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