Deleting Rows from a Datatable


#1

Hi,
I know there is a thread on Deleting Rows from a datatable, I had gone through that, and had posted my challenge there, but got no response, so trying with a fresh thread.

I have a DataTable with “No headers”. Its reading from an excel file and there are few rows in it with 3 columns each. The first column is a string . What I am trying to achieve is to Delete the rows that have the value “Engagement” in the first column.

I traversed through the datatable using For each… and used the assign activity to select the row with engagement as follows

DimensionData.Select(“Column0=Engagement”)

It gives me an error that Column0 not found. I was able to do the below assignment successfully.:disappointed_relieved:

DimensionData.Select(“Column0<>’’”)

Can someone help me achieve this using the Remove row activity or a regular For loop. :pray:

Thanks
Aman


Delete data row from data table
#2

Hi @a2dhanja

You can simply use an Assign activity like that:
outputDT = inputDT.Select("Column0 not like 'Engagement'").CopyToDataTable()

See attached xaml file:
SelectRows.zip (8.1 KB)

It selects all rows where Column0 is not Engagement.
You can also add some wildcards if you need to: "Column0 not like '*Engagement*'"


#3

Sometimes you have the nail, but you just dont find the right hammer. Thanks @loginerror for this ! :trophy:

Aman