LINQ query to update(replace)datatable in uipath

LINQ query to update(replace)datatable in uipath


Can you please share your condition and sample data @Rachel7

I have input data table as
Col1 Col2
123 ABC

I want to replace the empty value to “NA”

@Rachel7 should be technically possible, has done some statements very very close to this task

Great @ppr. Can you pls share it.

@Rachel7 Sure, but give me some time I have to rusch into several meetings in a few mins.

dt.Select(“[Col2] like ‘% %’”)
This will give you list of data rows then use for each then check if condition
row[Col2]=“” then take assign activity and give like this

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.Add(ra)).CopyToDataTable()

Use statement from above within an assign and assign it to an empty dataTable: dtCorredted

Before the assignment above create an empty datatable with the same structure as OriginDataTableVar by an assign: Statement - OriginDataTableVar.Clone
dtCorrected = OriginDataTableVar.Clone()


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