Hi everyone .
I have datatable in excel file as below.
I want to remove the first row if it has same value at 2 columns “name” and “code”
In below picture, it will remove row ( ajay , AA, 20 )
How to do that?
Thanks in advance!
Hi everyone .
I have datatable in excel file as below.
I want to remove the first row if it has same value at 2 columns “name” and “code”
In below picture, it will remove row ( ajay , AA, 20 )
How to do that?
Thanks in advance!
I have code as below… but it remove the last row… how to remove the first row
(From roww In table.AsEnumerable() Group By id=New With {key .i=roww.item(“name”),key .d=roww.item(“code”)} Into gg=Group Select gg(0)).copytodatatable
What if there’s three rows with the same values, do you also want to keep just the one row?
Hi Bro.
It only check 2 columns in datatable, if they same value then it will remove the first row duplicate out of datatable
sorry, anyone has solution ?
i have the code : “(From roww In table.AsEnumerable() Group By id=New With {key .i=roww.item(“code”),key .d=roww.item(“name”)} Into gg=Group Select gg(0)).copytodatatable”
But it do not remove the first row… how to customize to remove the first row ?
I have found solution via the link : Remove duplicate rows - Build / Studio - UiPath Community Forum
Thanks you!
Try the below code, but change it as per your requirement-
here DT1 is the output data table of the excel file
(From d In DT1
Group d By k=d(0).ToString.Trim, k1=d(1).ToString.Trim Into grp=Group
Select grp.Last()).CopyToDatatable
Note- k=d(0) and k1=d(1)
is the index number you can change it as per your requirement. like
k=d("name") and k1=d("code")
I am attaching a sample file for you
_testIndra.xaml (7.9 KB)
Try this and let us know the result.
BTW in your code, If you had just changed 0 to 1 then it would have worked, like below
(From roww In table.AsEnumerable()
Group By id=New With {key .i=roww.item("code"), key .d=roww.item("name")} Into gg=Group
Select gg(1)).copytodatatable
Thanks you bro
I recommend Distinct Method like below.
table.AsEnumerable.Distinct(System.Data.DataRowComparer.Default).CopyToDataTable
Very Simple!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.