Jump to content

IronPython Script to remove rows based on criteria


Vincent Thuilot 2

Recommended Posts

Hello

I would like to run a script which is removing rows from a table based on a column called "UserCheck" generated via a transformation.

Here is the script:

_________

from System import Environment, Threading

username = Threading.Thread.CurrentPrincipal.Identity.Name

Document.Properties["username"] = username

from Spotfire.Dxp.Data import DataValueCursor,RowSelection,IndexSet

from System import Convert

myTable=Document.ActiveDataTableReference

Userlist=[]

Userlist=DataValueCursor.CreateFormatted(myTable.Columns["UserCheck"])

RowCount=myTable.RowCount

rowsToFilter=IndexSet(RowCount,False)

for row in myTable.GetRows(Userlist):

if ["UserCheck"]"Yes":rowsToFilter.AddIndex(row.Index)

myTable.RemoveRows(RowSelection(rowsToFilter))

__________

For the moment it is removing every rows and I can't make it only removing rows for which the column 'UserCheck" is not"YES"

Any idea

 

Thanks a lot

Vincent

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...