Delete data row from data table

Hi @shrutika,

strvalue->string variable
strvalue="SOME Value"
data=data.Select("[COLUMN NAME] ='"+strvalue+"'").CopyToDataTable()

Regards, Arivu :slight_smile:

1 Like

Thank you. Works as expected

Is there a way to filter or copy data rows based on Index from a datatable.

HI @niteshvnr,
Try below code


Regards, Arivu :slight_smile:

1 Like


What about a list of variables?
I have a string of numbers: “21530,22035,22009”
I split them by {“,”}
so I got a string badList
now I want to pass them into
dataRow dataRemove =“[Durien] = '”+b+“'”)

instead of b but badList. I am thinking to use forloop but then the dataRemove value will be updated to select the 22009 rows only right?

I want it to select all the rows that contains 21530,22035,22009. Thanks

testDelete.xlsx (11.7 KB)
deleteInExcel.xaml (19.2 KB)

Edit: I used a nested for each loop and solved it! Thanks

Hi @lavint,

To remove the multiple rows by select condition. It has custom activity called “Remove Data Row Select” From BalaReva.DataTable.Activities. Below you can take more detail .



I like this approach!
If I would like to do the exact same thing, except for replacing the “Status” column name by the index number of the column, what should I change? I have been trying some stuff but it didn’t work unfortunately.

Hi @trabart,

You can apply like this

 dataTable.Select("[" + dataTable.Columns[0].ColumnName + "] = 1") 


1 Like

Thanks for your quick response.
I however do not understand it entirely.

Maybe it will help me if I refer to the example:
We want to remove all rows that contain “PV”.

We need to assign data.Select(“[Status]=‘PV’”) to data_to_del

Instead of selecting the column named [Status], I want to select the second column (with index 1).
What does the zero of Columns[0] represent, and does Columnname means the header?
And why is it equal to 1?

Can you elaborate on it a bit? :slight_smile:

 dataTable.Select("[" + dataTable.Columns[1].ColumnName + "] = ‘PV’") 


1 Like

Aaaah I still don’t get it. ): I just don’t understand what we are trying to do.
RemoveDatarow.xaml (11.3 KB)

Hi @trabart,

Here I have changed the xaml which you have attached it. And here I have attached it. (2.3 KB)



1 Like

Hi @trabart,

Please find the attachment
RemoveDatarowNew.xaml (8.2 KB)



Yaaaaay thanks! It works great!

Hi @aksh1yadav

I went through the entire thread but unfortunately, still havent been able to crack it. The difference in my case is. I have a datatable. It has no headers. I want to delete the rows where the first column (column0) contains the word “Engagement”.

when i use DimensionData.Select(“Column0=Engagement”) , it says it cant find Column0

I was able to use DimensionData.Select(“Column0<>‘’”) without any issues. not sure why its causing issues here.

I think we should be able to achieve this easily through “remove data row” activity , but since my challenge remains that there are no headers, I am still stuck.

If you can guide me through a single line, or loop logic, i’m ok with both.

Please help !

Hi there,

I was able to get it resolved by posting a parallel thread. Should anyone visit this page with the same issue, here is the solution

Thanks guys!

A comprehensive solution is attached. Below things are happening in the .xaml file
Directory: ‘C:\Temp’
Main File: ‘Sample.xlsx’ (Attached)
Requirement: Create a ‘Sample_Filtered.csv’ file with the same headers in the main file >> Delete all the rows except the header >> Copy rows from the main file where ‘Rate’ is greater than 175 >> Update the file.

Note: No impact is expected in Preformatted textthe main file.

Hope it will help in some or the other way.

Sample.xlsx (9.5 KB)
Delete-Append-Row.xaml (22.0 KB)

Dear All

please need support if i have column and i have many value but i iwant to remove any value start with (P & S) and keep remaining any support for that

thanks all for your support

Hello, what should be the expression in order to select the values in column [Status] and compare if lower than a local variable A?

Thaks a lot

Hi @Stefano_Skjupyter

It would look like that:

yourDataTable.Select("[Status]<" + localVariableA.ToString + "")

1 Like