RajeshCTS
(Rajesh Kumar Sahoo)
September 27, 2019, 2:30pm
1
My Input Datatable is -
Emp ID Equipment
772745 V
772743 P
772746 V
772745 P
772743 P
772746 P
Expected Output Datatable should be–
Emp ID Equipment
772745 V
772743 P
772746 V
datatable.DefaultView.Totable(True,{“Emp ID”,“Equipment”}) is not working for this case i tried.
Could you please post the solution using linQ as its processing a huge amount of data.
Luis261980
(Luis Nunes)
September 27, 2019, 2:46pm
2
Yes and its ok becouse if you read Emp ID + Equipment the are not the same
772745 V ← Is Not Equal to → 772745 P
Remove duplicates from Emp ID and do a a second lop at Emp ID en for each row if string.isnulorempty delete row
beesheep
(Eduardo Bernabe Sacahui Diaz)
September 27, 2019, 2:49pm
3
Hello @RajeshCTS
Welcome to the forum, if it’s necesary you can try this out:
(From p in inputDT.Select() where( From q in InputDT.Select() where q(“Emp”).Equals(p(“Emp”)) Select q).ToArray.Count=1 Select p).ToArray.CopyToDataTable()
DistinctRows_LINQ2.zip (8.0 KB)
However you can use remove dup rows activity:
If this answer your question please give it a like and mark it as solved
Regards
2 Likes
RajeshCTS
(Rajesh Kumar Sahoo)
September 27, 2019, 3:24pm
4
Luis ,
I need to remove duplicate rows (Emp ID should be distinct).Don’t consider the other column.
Have any linQ through which we can do it. Actually its a huge no of rows (60K>) so loop is not recommended
RajeshCTS
(Rajesh Kumar Sahoo)
September 27, 2019, 3:30pm
5
Bees,
It’s not working, its returning same datatable value as output. No filter happening for this.
Could you please send me the file .
Luis261980
(Luis Nunes)
September 27, 2019, 3:30pm
6
So use @ beesheep Robot Apprentice query
or use remove duplicate values activity, becouse your query will not work
RajeshCTS
(Rajesh Kumar Sahoo)
September 27, 2019, 3:46pm
7
Directly I am not reading sheet to get this duplicate value in data table. After some data processing only I am getting this duplicate value in data table.
beesheep
(Eduardo Bernabe Sacahui Diaz)
September 27, 2019, 4:17pm
8
@RajeshCTS Sure thing,
What steps have you done to complete this task, where you able to download the zip I provided you?
If you can share what you have done so far it’s much more feasible to help you
please come back to us with an XAML.
regards
RajeshCTS
(Rajesh Kumar Sahoo)
September 27, 2019, 7:01pm
9
Duplicate.xlsx (8.1 KB) Main.xaml (6.4 KB)
I am getting below exception and attached is the xaml file for reference
Source: Assign
Message: The source contains no DataRows.
Exception Type: System.InvalidOperationException
RemoteException wrapping System.InvalidOperationException: The source contains no DataRows.
1 Like
lakshman
(Ganta lakshman)
September 27, 2019, 7:26pm
10
@RajeshCTS
Try below expression.
newDT = datatable.DefaultView.Totable(True,“Emp ID”).CopyToDataTable
1 Like
Palaniyappan
(Palaniyappan P )
September 27, 2019, 11:10pm
11
Hi
welcome to uipath community
You were almost done
The expression be like
Yourdatatable = Yourdatatable.DefaultView.ToTable(true, “Column1”, “Column2” …,”Column n”)
Or we can simply mention like
Yourdatatable = Yourdatatable.DefaultView.ToTable(true, “Column1”)
Even one column duplicate is removed other will be neglected as well
Or to be more precise
Yourdatatablename = Yourdatatablename.AsEnumerable().Groupby(function(a) a.Field(of String)(“yourcolumnname”).Tostring.Toupper).Select(function(b) b.First()).CopyToDatatable()
Hope this would help you
Cheers @RajeshCTS
RajeshCTS
(Rajesh Kumar Sahoo)
September 28, 2019, 4:02am
12
Could you please check ,this statement is not working as i mention before and its returning only Emp ID column value not the Equipment column value.
My OUTPUT should be —
Emp ID Equipment
772745 V
772743 P
772746 V
RajeshCTS
(Rajesh Kumar Sahoo)
September 28, 2019, 4:38am
13
This LinQ working as expected . Without String Datatype can we create linQ with generic datatype, may be Emp ID will be double datatype.
RajeshCTS
(Rajesh Kumar Sahoo)
September 28, 2019, 5:14am
14
I did like this its working fine for all datatype
(From p In dt_input.Select Group p By ID=p(“Emp ID”).ToString into Group Select Group(0)).ToArray.CopyToDataTable
2 Likes
system
(system)
Closed
October 1, 2019, 5:14am
15
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.