Delete data row from data table

Excel Application scope try. it :slight_smile:.

worked out but it is filling the stake with the last item

image

Great :slight_smile:

Their is problem with your assignment or something… check your datatable content first before writing with output datatable activity in studio: :slight_smile:

Regards…!!
AKsh

Hi I would need to delete all odd numbers from table I just created. Can I use the .Select -method? And how?

Will you be able to explain a bit more with description or expected input or output

Thanks


Yeas, so at the moment this is what I have. The Output looks something like:
7
3
6
4
10
5
etc…

But I would like to delete all odd numbers. In this case the ouytput would be like:
6
4
10
2
etc… (So only even numbers)

hey @naample

please find attached sample :slight_smile: sample for even values of a col.xaml (11.6 KB)

Regards…!!
Aksh

1 Like

Thank you so much :slight_smile:

@aksh1yadav … Please can you suggest something for below scenario.
I have data in two data tables DT1 and DT2 . I want to delete data from DT1 if dt1.empid = dt2.contractorid .

I have taken two for loop and in inner for loop I have if condition with this check(dt1.empid = dt2.contractorid).
but its not workign, throwing exception.

Hi @narayan_shrawagi,

Datatable->Dt1
Datatable->D2
User for each row activity ->Dt2

use Assign activity
Dt1=Dt1.Select("empid <> '"+row("contractorid ").Tostring()+"'").CopyToDataTable()

Regards,
Arivu

hey @narayan_shrawagi

If you will read all post in this thread above you can get your approach and idea.

you can instead of delete much rows take only those data which is needful for next step so just check your idea from above existing post and get the actual context and if still face any prob let me know.

Solution Without Usign for each:

Datatable result = DT1.AsEnumerable().Where(function(row) Not DT2.AsEnumerable().Select(function(r) r.Field(Of Int32)("Contractorid")).Any(function(x) x = row.Field(Of Int32)("empid"))).CopyToDataTable()

Sample To check: - datatable column match.xaml (10.7 KB)

REgards…!!
Aksh

3 Likes

try while loop instead of for loop if you want to use Remove Datarow

@aksh1yadav Thanks Akash for sharp reply. Its working now :slight_smile:

Hi I have a task in which i have build a data table. Now the is one column Aging (Double) now i have to filter data condition is: if row(“Aging”) is greater than 0.35
then populate data table with these values.
Please help @aksh1yadav @
Mr_JDavey

Hi, question, I tried your solution, but I get an error saying
“‘DataRowCollection’ does not have a public instance method named ‘Remove’ matching the parameter types, generic type arguments, and generic type constraints supplied to InvokeMethod ‘Invoke method’”

I did see you filled in the parameters of the invoke method, but when I do that I get another error, on the item, saying:
“Compiler error(s) encountered processing expression “item”. Option Strict On disallows implicit conversions from ‘Object’ to ‘System.Data.DataRow’.”

As far as I can tell I did everything just like you did it. Do you know of anything I might be overlooking?

Thanks in advance!

According to this page (https://www.uipath.com/kb-articles/how-to-filter-a-data-table), you would type “Aging>0.35” instead of the “[Status]=‘PV’” part in the select method.

Hope that works for you!

You have to change the Datatype of your argument to System.Data.DataRow.

Regards…!!
Aksh

You mean the Datatype of the value in the parameters? Or the datatype of the “item” in the for each loop? Cause they both are datarows allready as far as I know. Item is an item from an array of datarows, and the value is also set as a datarow. It is exactly the same as in your example, but somehow it doesn’t recognize the item as a datarow it seems…

Will you be able to share your sample workflow and screenshot if possible?

REgards…!!
Aksh

I can’t send the workflow because of the client, but it works very similar compared to you example. Here are some screenshots to show the process and the variables.

Thanks in advance!