need to remove duplicates in two columns (Customer Code,Jurisdiction Name) the attached sheet and also keep rest of all the column values.
if I use dt_Inputsheet.DefaultView.ToTable(True,“Customer Code”,“Jurisdiction Name”) syntax I am getting these two columns alone in the output dt . but i need rest of all the columns and corresponding values.
This always results the number of coulumns considred for distinct.
You can do like, keep the above resulted data as reference table and original data in another table. Run it in a for each loop and when the reference data matches write the original data row to new datatable .
here we do need some sharp definitions as removal can be understood as:
deduplication - but which one from the duplicates is to keep e.g. other col vlas are different
removing all duplicates
give a try on following:
keeping from duplicates the first along the other rows
(From d in dtData.AsEnumerable
Group d by k1=d("Customer Code").toString.Trim, k2=d("Jurisdiction Name").toString.Trim into grp=Group
let mbr = grp.First()
Select r=mbr).CopyToDataTable
remove duplicates and keep only the non duplicate ones
(From d in dtData.AsEnumerable
Group d by k1=d("Customer Code").toString.Trim, k2=d("Jurisdiction Name").toString.Trim into grp=Group
Where grp.Count = 1
Select r=grp.First()).CopyToDataTable