I am merging to data table, 1 data table is from early this morning with data in it,
I have another newer data table I just scraped
both have same column names
There is a good chance they will have the same data plus more in the newer data table
I can merge both tables, however I want to remove all duplicates, not just 1 set of duplicates
All I want to be left with is rows that had no duplicates.
Is there a way to do that?
I tried 'remove duplicate rows, which it did, just not the way I thought it would.
Any Assistance is greatly appreciated
e.g
DT1
Fred, John
DT2
Fred, John, Sam
I want to merge both DT1 and DT2 (this works fine), however then remove duplicates, so all I have is
DT3
Sam
I run all the way through until that assign using the same code as in the post. I did change the variable names to match my data tables, not sure why it would give me this error.
below is my 2 data tables, red indicates the names
This is a tool that is built into Excel and located on the Data tab of the ribbon.
Advanced Filter has a checkbox labeled “Unique records only” that will remove duplicates and output a list of unique values to the specified range.
Here’s and instruction guide on how to remove duplicates to create a list of unique values with Advanced Filter:
Click the Advanced Filter button on the Data tab of the Ribbon.
Select the “Copy to another location” radio button.
Select the “List range”. The range/column that contains the duplicate values.
Select the “Copy to” range. The cell where the new list of unique values will be output to. Should be a blank column.
Click the “Unique records only” checkbox.
Click the OK button.
The Advanced Filter will paste the values of the unique items starting in the cell specified in the “Copy to” range.
So in short you are looking for a right join of two datatables Dt1 and Dt2. In UiPath the join datatable activity does not give options for Right Join (Dt1, Dt2). But there is a work around to achieve this consistently.
Step 1. Assuming you have a single column DTs (Dt1 and Dt2), first you can use a Join Data Table activity. Here I do a left join because Dt2 is having the extra unique value, but you can adjust it as per your case. Saved this as JoinedDataTable.
Step 2. Make a clone of any one of your input DataTables here I clone Dt1. This is done so that we can get the headers and type of the items in the DataTable. Lets save it as OutputDataTable
Step 3. We use For each Row activity and loop through the JoinedDataTable. Here is the interesting part. Logically, we do not want any values which appeared in both Dt1 and Dt2 only unique values (Sam) so make an if condition where we check row("Name_1").ToString.Trim.ToLower.Length = 0 This “Name_1” column was one of the output columns from Join DataTable activity in Step 1.
If the condition is met, add a row to the OutputDataTable. Else do nothing.