How to Compare two datatable, and have a single notification

Hello
I have a problem in performing a comparison between two tables, which must end with a single notification.

After a series of scrapings, I collect two such tables, let’s say.
image

My goal is to make a comparison between the two, which must give only one notification of OK if they are identical, and of KO if they are different.

at this time I used a code of this type.

The problem is that the control being on all lines, it returns me for the first line, the notification of KO, and on the second of OK.
I need a check on the table, “absolute”.

That is, only if all lines are the same, OK
if not, KO.
In this case, KO.
Can help me with this?

A

1 Like

I’ve tried this, outside the “For Each” loop, but the notification always KOs, even if the two tables are the same.
I do not understand.

Hi ,

This can be tried using the Linq
DTSame = DT1.AsEnumerable().Except(DT2.AsEnumerable(),System.Data.DataRowComparer.Default).CopyToDataTable

If DTSame.Rows.count>0 then “KO”
Else “OK”

Refer this link

2 Likes

Hi

Fine

Use this expression in a IF condition which will give you a notification on comparing two datatables

Dt1.Rows.Count.Equals(Dt2.Rows.Count) AND
Dt1.AsEnumerable().Except(Dt2.AsEnumerable(),System.Data.DataRowComparer.Default).CopyToDataTable().Rows.Count.Equals(Dt1.Rows.Count)

If the above condition is true it will go to then part where use a assign activity with value as “OK” or goes to else part with value as “KO”

Cheers @AaronMark

Thakns at all…
and… Not Work well… Unfortunately.
I also need to consider the contents of the cells.
I did some tests but without success.

I found an alternative route by doing so, perhaps.
I don’t have much experience, can you tell me whether to see problems that I don’t see?
It seems to work, but being a bot in production I would not take the risk.


then in if

?? thanks…

Fine

  • first condition is fine
  • what is the value of variable l in row(l) in second IF condition
    Kindly clarify that

@AaronMark

I added an Index
in the properties of the for each loop.

image

BOT1-Coupa_Snow.xaml (1,0 MB)

@AaronMark

Check below for your reference

https://forum.uipath.com/t/rpa-datatable-get-previous-row-column-value-set-to-current-row-column-value/256199/2

Hope this helps you

Follow Link

Thanks