Delete data row from data table

datatable
excel
activities

#63

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:


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

Regards
Balamurugan.S


#65

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


#66

Hi @trabart,

Here I have changed the xaml which you have attached it. And here I have attached it.

RemoveDatarow.zip (2.3 KB)

image

Regards
Balamurugan.S


#67

Hi @trabart,

Please find the attachment
RemoveDatarowNew.xaml (8.2 KB)

Regards,
Arivu


#68

Yaaaaay thanks! It works great!


#69

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 !
Thanks
Aman


#70

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!


#71

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.

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


#72

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
B149F0DA-B98F-4E2D-A669-AEB9BF9C61B1


#74

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
Regards


#75

Hi @Stefano_Skjupyter

It would look like that:


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


#77

Hello @balupad14

If i want to select the row in column [Tiltle] that contains the string written in the variable temp.

For example if “the” is contained in “the sun is bright”

With this code i have an error
DT1.Select("[Title] like ‘"& temp &"’")

The error is: can’t find the column named “The”
But infact i want to look if “The” is contained in a sentence written in a cell of the column [Title]…

Can you help with that?


#78

Hi @aksh1yadav are you sure this the right syntax? to look if a string is contained in the column?

Thanks


#79

Hey @Stefano_Skjupyter

Now seeing this topic and noticed Actually at the time of post i have not preformated text so you guys were not able to see
dt.Select("[Col1] like ’ Forward: '") as it’s original form

it was
dt.Select("[ColName] like '*Forward:*'")
or also you can below too

dt.Select("[ColName] like '%Forward:%'")

Now answer to your Question :slight_smile:

Yes it is :slight_smile:

you can use one of the way:
dt.Select("[ColName] like '*Forward:*'")

or

dt.Select("[ColName] like '%Forward:%'")

Regards…!!
Aksh


#80

@aksh1yadav thanks for the answer, i have a execution error saying, “Cannot perform ‘Like’ operation on System.Double and System.String”
What the reason for that? are all strings…


#81

Hey @Stefano_Skjupyter

The Column datatype is double in excel. Cross check please

Internally ReadRange gnerates DataTable with types set for all columns as Object, but individual cell types are determined by what type Excel assigned.
This means that a value of “aksh12” will be stored as a String, but “12” as a number (so Double).
You can check it by iterating and checking the Type of each object :slight_smile: Too

so just try this : - dt.Select("Convert([ColName],System.String) like '%Forward:%'")

Reference Thread - DataTable Select function cannot perform “=” operation on System.Double and System.String

Regards…!!
Aksh


#82

Thanks a milion @aksh1yadav it works!!


#83

@aksh1yadav

Having a similar trouble.
I have an integer in a datatable, Using the Get Row Item activity I have the error " string converter cannot convert from System.Double"

After i have to compare if the data is lower than another. How should I set properly the conversion?


#84

Hey @Stefano_Skjupyter

Do you mean a Column datatype is Int?

May i know how your using it? Any Screenshot?

To fix it just do like a sample screenshot. :slight_smile:

Regards…!!
Aksh