How to avoid duplicate value one excel to another excel

Hi Team,

I have 2 excel , excel 1 Ac no and Ab no and excel 2 have same Ac no and Ab no , if excel 1 Ac no and Ab no both number found in excel 2 i need to skip else i want append excel 1 to excel 2

excel 1
image

excel2
image

Expected output:
No need to append why because excel1 5555 6666 those number found in excel2 if not found those no i want to append.
Combination of number(“Ac no” and “Ab no”) to find duplicate based on the count if count =0 i should append else skip

Pleases any one help me for this

Regards,
Raja G

@Raja.G

You can do this

  1. Read the first excel in to dt1 and second into dt2
  2. dt1.AsEnumerable.Except(dt2.AsEnumerable,DataRowComparer.Default).CopyToDataTable - this will give the rows which are not present in dt2 but present in dt1
  3. Use append range and pass the new datatable

Hope this helps

Cheers

Hi @Anil_G ,

Please can u elaborate i didn’t understand

@Raja.G

  1. First step I am reading both the datatables using read range
  2. in the second step we are using assign activity to create a new datatable which has the rows from dt1 but no matching rows from dt2 are to be present…for that we are leveraging except method to remove the matching records
  3. Append all the obtained data from step2 which is basically the unmatched data into the excel 2 as needed

You can as well use this linq in the second step

dt1.AsEnumerable.Where(function(x) Not dt2.AsEnumerable.Any(function(y) y("Col1").ToString.Equals(x("Col1").ToString) And y("Col2").ToString.Equals(x("Col2").ToString))).CopyToDataTable

Cheers

1 Like