Remove duplicates in excel

datatable
excel
activities

#1

Hi
I want to remove duplicate rows by comparing the rows of the same column. If the content of row1 is ma to row 2 then delete row1 and so on till the end of selected rows.
example
column1
abc
abc
def
abc

output
abc
def
abc

plz proveide the solution with xaml file.

Thanks


#2

Hi @Atul_Rai,

You could do it by using by the Remove Duplicate Rows activity Or using the following code:
DataTable distinctTable = dtRows.DefaultView.ToTable(true, "column1");


#3

thanks @acaciomelo. can u provide the xaml


#4

Hi @Atul_Rai,

Atul_Rai is right. But in the uipath also is having the activity to remove the duplicates by “Remove duplicate rows” activity. Below you can take an overview with the example.

Regards
Balamurugan


#5

HI @balupad14,

Thanks for the reply.I am using studio. I don’t have “remove duplicate rows” activity. I tried to do it using loop but it is not working. I tried with following link:
https://www.uipath.com/kb-articles/excel-automation-delete-duplicate-rows .


#6

Hi can you please. Check this


#7

Hi @acaciomelo
The code “DataTable distinctTable = dtRows.DefaultView.ToTable(true, “column1”);” will give me distinct values but I want to remove only the row which are cosecutive and keep 1 row.
example
I have a list of program to be broadcast in a day. A program will have repeat telecast also. So i want to remove the program name if they appear twice or trice consecutive only.
Like

program name
drama -1
drama -1
movie -1
drama-1
drama-2

output
drama-1
movie-1
drama-1
drama-2

I hope this time I am much clear with the problem statement.
Thanks


#8

Well, in this case you could iterate the rows and check if the current value is not equal to the previous one. If they are different, then you may apply the value, otherwise you may continue the loop.

Keywords: for each row, continue;

Please, try to follow this logic and let me know. :slight_smile: