Comparing lines from DTs

I have two DTs and I want to see if each line matches the other line. How can I do this without Excel? Currently, I’m writing each DT to a tab in an Excel document and then using =IF(CD!1:1=PD!1:1,“True”,“False”) and then I read that column with the function and if I have a value of “false” then I know there is a mismatch in data between the two tables.

hi @rgardner5564,

use this,

MatchedDT (DataTable) = Dt1.AsEnumerable().Where(Function(row)  Dt2.AsEnumerable().
Select(Function(r) (r.Field(Of String)(0)).Trim).Any(Function(x) x = (row.Field(Of String)(0)).Trim)).
CopyToDataTable()

this will give you matched rows from both your dts and copy it to a new datatable

1 Like

@rgardner5564

Check as below

https://forum.uipath.com/t/tutorial-how-to-check-a-string-is-present-in-excel-sheet-part-1/243696/2

https://forum.uipath.com/t/tutorial-check-value-exists-in-excel-sheet-using-uipath-part-3-without-using-foreach-loop-filterdatatable/247533/3

Hope this helps you

Thanks