To Remove Duplicate Rows

Hii Team,

In UiPath Activities we have Remove Duplicate Rows Activity

Can we have a LINQ for the same

Have tried Remove Duplicate Rows Activity
That’s working fine but its a bit slow so can we have a linq for the same

Thanks Team in Advance

@NISHITHA

You can try this

dt.DefaultView.ToTable(True)
dt.AsEnumerable.Distinct(system.Data.DataRowComparer.Default).CopyToDataTable
1 Like

Yes @NISHITHA We have LINQ which is very efficient & time saver as well, Let me know the input excel or Datatable you want to filter(remove duplicate) you can share a dummy table if data is confidential or a screenshot of input datatable is enough, I’ll help you out!

Regards,
Ajay Mishra

Hi @Ajay_Mishra

The Duplicate Rows are not based on Single Column

Example
image

Inthis

After Performing LINQ it would be

image
TestDataDuplicate.xlsx (4.8 KB)

1 Like

Hi @Shiva_Nikhil

Thanks for the prompt response

1 Like

Okay @NISHITHA

Output is ready!

Assign Activity:
dt_Output(This is new Datatable vairable) = dt_Input1.DefaultView.ToTable(True)

I’m attaching the .xaml. just check.
Remove_DuplicateRow.xaml (7.7 KB)

Input & Output Excel:
TestDataDuplicate.xlsx (8.1 KB)

Regards,
Ajay Mishra

hello @NISHITHA ,

You can use this linq to remove the duplicates,

Out_Dt=(From row In in_DT.AsEnumerable() Select row).Distinct(DataRowComparer.Default).CopyToDataTable()

as you can see in below screenshot

F_Linq

I am attaching the .xmal file for your reference,

Remove duplicates.xaml (7.6 KB)

Regards,
Dheerendra Vishwakarma

@NISHITHA

use this

dt.AsEnumerable.Distinct(system.Data.DataRowComparer.Default).where(Function(a) not a.ItemArray.All(Function(b) b.ToString.Equals(""))).CopyToDataTable

Hey @Shiva_Nikhil,

I think you didn’t got the question!

1st Table is Input and 2nd table is Ouput, and in your solution you are including both the tables as input. So, its not correct!

Regards,
Ajay Mishra

@Ajay_Mishra

See my first post you have given the same solution

I have shared the output not the input.

In output 1 is Removing duplicates having empty row
In output2 is removing empty row as well