I am having a excel in format
Now I want to delete all the row where Status=“PV”.
Please suggest a solution. I want to perform this action using one database table only.
I am having a excel in format
Now I want to delete all the row where Status=“PV”.
Please suggest a solution. I want to perform this action using one database table only.
Hey @mgangrade7
To delete rows from datatable, you could use the logic like this:
For Your Reference find the attached sample solution: Delete_Data_Row_From_Datatable.zip (7.7 KB)
Regards…!!
Aksh
@aksh1yadav: Why not using RemoveDataRow
instead of InvokeMethod
?
SAMPLE1.xlsx (8.6 KB)
@aksh1yadav How to remove if complete row is blank row.For Example i am attaching xlsx file .In this xlsx file 4th row is completly blank row. how to remove this row ?
Just Use the If condition to check those required columns are blank or not then if they are then use Remove data row activity .
@aksh1yadav In your attached Delete_Data_Row_From_Datatable.zip in assign field you are assiging data.Select(“[Status]=‘PV’”).where i need to use if condition,can you please share the xaml file for this ?
this statement returning the rows which are having status ‘PV’. so you have to modify it something like this for your requirement
DataTable.Select(“[COLUMN 1]=‘’ OR [COLUMN 2]=‘’”)
and if null values you have then you can use like this:
DataTable.Select(“[COLUMN NAME] is null”);
and then you can easily inside for each loop ,can use Remove data row activity.
Regards…!!
Aksh
@aksh1yadav when i am providing properties for Remove data row Activity, i am getting an error and not able to resovle this one.For reference i am attaching my xaml file.Can you please help me regarding this issue so that i can delete my blank row from xls file.DeleteBlankrow.zip (7.9 KB)
Suppose if i want to delete a row in which a column contains a particular string…How to do that…?
Hey @Sam
You have yo use similar Datatable.select() with your column name and string then it will return an array of DataRow. then you can use Foreach loop and inside Remove data row activity pass that filtered row item.
Regards…!!
Aksh
ok i got that.
but Suppose in a datatable i want to remove those rows in which a column contains a particular word “Forward”.
for example- my string is “Forward: UiPath v/s blueprism”. I want to remove all those rows which contains this word “Forword”. ?
**Datatable.Select("ColName LIKE '*Forward:*'")**
to filter those rows.
Regards…!!
Aksh
Hi rahul like here you have put PV but i need to delete row which are not equal to a string variable how should i delete row then as variable value keep on changing
Hi aksh1yadav like here you have put PV but i need to delete row which are not equal to a string variable how should i delete row then as variable value keep on changing
My column name is ENODEB and my variable is Current_SiteID. so in a data datable if row is not equal current_siteid ,then delete row
Hi there @1vivek12.
You can do the following:
dtMyDataTable = dtMyDataTable.AsEnumerable.Where(Function (x) x.Item("ENODEB").ToString.Trim.ToLower.Equals(current_siteid.Trim.ToLower) = True).CopyToDataTable
This will return a DataTable where all rows meet your criteria (‘ENODEB’ column = current_siteid).
Thanks,
Josh
Thanks a lot Josh worked like magic.no need to delete row now.Thanks! and will help with other things as well.
Hey @Mr_JDavey i need to remove duplicate row based on rows in column Sector_ID. can you help with that too!