Finding non-matching datatable rows (multiple columns)

Hi there,

I’m currently trying to compare two datatables, and return the items from one DT that don’t match.


Datatable 1 - “NewClientData”

Datatable 2 - “ExistingClientData”

I’m trying to use the following in the Assign variable, to only bring back the items that don’t exist/completely match in NewClientData, but for some reason it’s still bringing back everything, even the duplicates:

OutputDT = NewClientData.AsEnumerable().Except(ExistingClientData.AsEnumerable(), DataRowComparer.Default).CopyToDataTable

Ultimately I’m expecting to see the following data returned in my OutputDT datatable, because the exact data doesn’t exist at all in ExistingClientData:

Would anyone be able to advise on where I may be going wrong here?

Thanks in advance

A quick follow up here - I’ve just ran my process (which involves downloading ExistingClientData) and it didn’t work as expected (it returned all items from NewClientData, even if it already existed in ExistingClientData)…however…I’ve just gone into the CSVs for ExistingClientData and NewClientData, clicked save on each file, ran the process again, and it then ran fine and brought back the differing rows… :thinking:

Is this some kind of bug? or is there something in my datatables which may be causing a disconnect?

this can happen when both datatable do have differences e.g. within Column.DataTypes
And/Or other not easy visually to detect differences

Use the immediate panel
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

and type in

dt1.columns.Cast(Of DataColumn).Select(Function (x) String.Format("{0} - {1}{2}",x.ColumnName, x.DataType.toString, vbCrLF)).toArray

dt1 - repalce with your Variablename and check both schemas

Hi @ppr thank you for this. Unfortunately I’m still having issues - the data types all look to be the same, which is very strange. Oddly as well, if I go in and out of one of my CSVs (the data that ends up being added to that CSV/datatable comes after using the Read Range workbook activity) and save the file, the action then performs as expected. Do you know why re-saving the CSV may cause this to suddenly work?

@ppr I think I’ve managed to fix this! I’ve saved all of my datatables into separate Excel files, and then used a Read Range on each of those files to get them back into new datatables :sweat_smile: I think it stemmed from one of my original DTs deriving from an Excel file in a previous workflow (so the type was System.Object) whereas the other was of type System.String.

Thanks again for your help debugging this!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.