tREX
(tREX)
October 30, 2020, 11:09am
1
Hi,
I read in an excel sheet that is very large and i want to filter the rows based on a string (filteredValue). This method works but takes several minutes to execute due to the size of the data table i presume. is there a faster way to do this?
New to UiPath so thanks for the help
ppr
(Peter Preuss)
October 30, 2020, 11:23am
2
@tREX
Welcome to the forum
you can try if it is faster:
Assign Activity
Left side: dtFiltered - datatype: Datatable
right side:
yourDTVar.AsEnumerable.Where(Function (x) x("Column0").toString.Contains(filteredValue)).CopyToDatatable
In case of the risk of empty filter results apply following pattern:
1 Like
tREX
(tREX)
October 30, 2020, 11:55am
3
Hi, Thanks for the help. not sure if i am doing it correctly. see below.
ppr
(Peter Preuss)
October 30, 2020, 12:01pm
4
@tREX
just do directly with adopted variable names:
Variables
drFiltered - List (Of DataRow)
dtFiltered - Datatable
Assign:
drFiltered =
dt_DCMaster.AsEnumerable.Where(Function (x) x(“Column0”).toString.Contains(filteredValue)).toList
if Activity
then: dtFiltered = drFiltered.CopyToDataTable
else: dtFiltered = dt_DCMaster.Clone
thats all
jibanjyoti
(Jiban Jyoti Rana)
October 30, 2020, 12:17pm
5
Hi @tREX
Welcome to Forum.
Check the above link, it explains 4 different ways to filter a data table.
Thanks,
Jiban
tREX
(tREX)
October 30, 2020, 12:27pm
6
Hi again,
So i tried as you said but it is showing no matching rows even though there are.
The filterderValue String is “Birdwatch” which is one of the first rows shown below
ppr
(Peter Preuss)
October 30, 2020, 12:34pm
7
@tREX
can you please crosscheck this part:
x (“Column0”).toString.Contains(filteredValue)
tREX
(tREX)
October 30, 2020, 12:40pm
8
Okay that is working well now. Thank you very much.
Would i need the empty filter results part at all so?
ppr
(Peter Preuss)
October 30, 2020, 12:44pm
9
Didn’t get you.
CopyToDataTable throws an exception if the filter statement is empy and returns no rows. Thats why we do apply this pattern in case of we cannot rely on a mandatory non empty filterresult
tREX
(tREX)
October 30, 2020, 1:30pm
10
Thanks again. Just one last question. How to compare the data table to the string without upper case or lower case affecting the resulting filter?
ppr
(Peter Preuss)
October 30, 2020, 1:57pm
11
Are you looking for a canse insensitive filtering?
give a try on
x(“Column0”).toString.toUpper.Contains(filteredValue.toUpper)
1 Like
system
(system)
Closed
November 2, 2020, 1:57pm
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.