Hi Team,
i have two datatable to compare
use this linq
“Dt_Sh1.AsEnumerable.Except(Dt_Sh2.AsEnumerable(),System.Data.DataRowComparer.Default).CopyToDataTable” and get output but i want write the status columns which columns is not match… Can tell me how to write the status.
Thank
shyam
@Shyam_Pragash
This query will not work
Can you provide any sample input and output
Cheers
Anil_G
(Anil Gorthi)
September 28, 2023, 8:22am
6
@Shyam_Pragash
Did you add dt2 as only in parameter or in out?
Please set argument direction as in
cheers
Yoichi
(Yoichi)
September 28, 2023, 8:36am
7
Hi,
Can you try the following sample?
listStatus = dt1.AsEnumerable.Zip(dt2.AsEnumerable,Function(r1,r2) String.Concat(Enumerable.Range(0,dt1.Columns.Count).Select(Function(i) if(r1(i).ToString=r2(i).ToString,"",dt1.Columns(i).ColumnName+";")))).ToList
Then add datacolumn
Next
dt1 = dt1.AsEnumerable.Zip(listStatus,Function(r,s) dt1.Clone.LoadDataRow(r.ItemArray.Take(dt1.Columns.Count-1).Concat({if(s="","Match",s+" NOT Match")}).ToArray,False)).CopyToDataTable
Sample20230928-6L.zip (9.3 KB)
Regards,
Anil_G
(Anil Gorthi)
September 28, 2023, 8:48am
9
@Shyam_Pragash
As mentioned please change dt2 to in only and not in/out
cheers
Hi @Yoichi
As per your sample input working fine…
But Uneven of rows of sheet1 and sheet2 but getting wrong output…
Yoichi
(Yoichi)
September 28, 2023, 8:58am
11
Hi,
Can you share input data as file?
Regards,
Hi @Yoichi
i have 45 columns some data… but can’t share you…
Only Two columns of input data shared you.
Input.xlsx (9.0 KB)
Thanks
Shyam
Yoichi
(Yoichi)
September 28, 2023, 9:05am
13
HI,
This data doesn’t seems same as the following which you uploaded in previous post.
Can you also share expected output for the above input?
Regards,
Hi @Yoichi
for Understanding purpose i share.
On Input based how to write the status columns…
i expected output in status columns
Yoichi
(Yoichi)
September 28, 2023, 9:14am
15
Hi,
As Sheet1 has 14 rows and Sheet2 has 15 rows, it’s difficult to compare items of same row number.
If you don’t need to compare items of same row number, it’s difficult to find which item is different.
Regards,
Hi @Yoichi
Okey Thanks
On Your previous code… can able check multiples columns in a sheet1 and sheet1 ?
Thanks
Shyam
Yoichi
(Yoichi)
September 28, 2023, 9:21am
17
HI,
Yes, it can handle multiple columns. Please note that it compares items at same row number and same column number.
Regards,
system
(system)
Closed
October 13, 2023, 5:39pm
18
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.