Identify if there is any duplicate values in excel column

i want to identify if there is any duplicate values in excel column and leave only one value and delete the rest

for example:

image

Thanks

from the description we cannot derrive a complete detail set.

assumptions:

  • identfy duplicates on the name value
  • when duplicates are found, keep the first member from the duplicates set

Assign activity
dtResult =

(From d in YourDataTableVar.AsEnumerable
Group d by k=d("name").toString.Trim into grp=Group
Select r = grp.First()).CopyToDataTable

I explain it more detailed:
in the image i checked the “name” Colum and need to find if there any duplicated values.
if there is any i will need to delete (regarding what there is in the other colums) and left with only one value in the “name” Colum

thanks,

give a try at the given statement from above. It should be close / match the need

Sorry
dont understand what you meen / written

here we gave you a working snippet, which can be used within an assign activity.
instead of YourDataTableVar just use your variablename of the datatable, retruned e.g. by read range when reading in the excel

Thanks for helping
i used as you written, but at the end of this process the excel sheet remains the same - doesn’t delete any values

thanks,

Hi @nir.kail ,

Can you try this

DT.AsEnumerable().GroupBy(Function(x) x.Field(of String) (“name”)).Select(Function(y) y.First).copytodatatable

Thanks!

just write back the resulting datatable to a new worksheet e.g. with a write range and check the result so far

for inspection of part results you can use e.g. the immediate panel:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Hi’

still the same

thanks

so share your implementation details and/or xaml along with sample data

MHRA_Case_Download.xlsx (10.1 KB)
Main.xaml (231.4 KB)

when following step should write out the deduplicated datatable:
grafik

then you should use dtResult

However as mentioned above, Partresults can be checked within the debuging panels

did it
but doesnt delete this duplicates values

using your data:

And the statement from above (adapted to variables, colname)
grafik

will produce:
grafik

so, when any different output is needed then just reformulate your requirements more clear and detailed. In general it is showcasing what was requested so far:

hi
sorry for taking time from last comment

this process does not work at my studio
it left me the excel sheet with the same (duplicate values)
after it is running this is the log:

Hii @nir.kail ,
Can you please crosscheck which DataTable Variable you have put in the Log message. I think by mistake u have put the Input DataTable I guess .Because if you use the below query
DT_Output :- (
From row In DT_Input.AsEnumerable
Group row By a=row(“MESSAGE NUMBER”).ToString.Trim Into grp=Group
Select grp.First
).CopyToDataTable

You should be able to get the required output which we are getting. If not I have dropped the Xaml please try to run that and let us know if that doesn’t work
Main.xaml (7.2 KB)

3 Likes