aslam_ali1
(aslam ali)
October 30, 2023, 11:35pm
1
Hello friends
I have one datatable. first im filtering some lines out of 100 lines based on some condition and performing some operation.
After the operation is performed i have to update all filtered lines as failed or success in the same data table . I can do this by for each but it takes more time, is there any faster way to do it.
Thanks in advance…
@aslam_ali1
you can use LINQ to update the rows:
DT.AsEnumerable().Where(Function(row) 'Your condition here').ToList().ForEach(Sub(row) row("Status") = "Success")
DT.AsEnumerable().Where(Function(row) Not 'Your condition here').ToList().ForEach(Sub(row) row("Status") = "Failed")
1 Like
Use a assign activity and have this one linq query to update ur column value for all rows using linq
dt = dt.AsEnumerable().ToList().ForEach( Sub(row) row("Status") = If('Your condition here', "Success", "Failed") End Sub)
U can a replace the text Your condition here like
row(“yourcolumnname”) = “this value”
For more such Datatable functionalities
Refer this
Hi All,
Datatable - variable type is the most commonly used variable type by all UiPath users
And it’s been the most often asked queries in forum especially on its manipulation
So I would like to have this post as a repository for those who are looking for expressions related to Datatable
Let’s go one by one keeping dt as name of datatable variable
1. Get number of rows in a datatable dt
dt.Rows.Count (output - int32 type)
2. Get number of columns in a datatable dt
dt.Columns.Count (output…
Hope this helps
Cheers @aslam_ali1
AMAN_GUPTA
(Aman Gupta)
October 31, 2023, 4:37pm
4
Hi @aslam_ali1 ,
Please use linq for faster processing.
system
(system)
Closed
November 3, 2023, 4:54pm
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.