How to remove these

how can i do this i have 2 excels

data1 : has lot of data
D2 : has few

now i want to remove that transaction i.e D2 data to be removed from new and rest to saved in new

D2.xlsx (8.2 KB)
D2.xlsx (8.2 KB)

Assumption: 1 column as the samples show

  • read range excel1 out: datatable - dt1
  • read range excel1 out: datatable - dt2

Assign activity:
dtResult = dt1.AsEnumerable(dt2.AsEnumerable, DataRowComparer.Default).CopyToDataTable

  • write range - dtResult to a new Worksheet
1 Like

@manoj_verma1

Please try this

dt1.AsEnumerable().Except(dt2.AsEnumerable(),System.Data.DataRowComparer.Default).CopyToDataTable

Has to be used in assign…and of left have a datatable

cheers

Hey @manoj_verma1

image

Or

Hope this helps
Cheers.

in Addition to above, when the datatable has more columns but we have to check only on column, it can be modelled as a isMatch case, without for each loop modelling:

  • read range excel1 out: datatable - dt1
  • read range excel1 out: datatable - dt2

Assign activity:
dtResult =

(From d in dt1.AsEnumerable
Let c = d("Column1").toString.Trim
Where Not dt2.AsEnumerable.Any(Function (x) x("Column1").toString.Trim.Equals(c))
Select r = d).CopytoDataTable

Handling empty filter results:
:ambulance: :sos: [FirstAid] Handling of The source contains no DataRows exception - News / Tutorials - UiPath Community Forum

2 Likes

dtresult will be of which type @ppr

Datatype: DataTable

getting error asEumerable not a member @Chirag_Shetty_Divakar @ppr

1 Like

Sorry @ppr @manoj_verma1

It should have been From r In dt2.AsEnumerable istead of From r In dt2.AsEnumerable mybad.

Regards.

AsEnumerable is the method name

@manoj_verma1

You can fix it by adding the Assembly Reference manually in your xaml file:
image

Simply open the file in Notepad and create new line with this String:
<AssemblyReference>System.Data.DataSetExtensions</AssemblyReference>

Then reopen your project and the error should be gone.

Cheers.

4 Likes

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