Vincent Thuilot 2 Posted July 31, 2017 Share Posted July 31, 2017 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 More sharing options...
Shandilya Peddi Posted July 31, 2017 Share Posted July 31, 2017 Hello Vincent, Replace your IF condition withthe following line of code and this should fix your issue, if Userlist.CurrentValue"Yes":rowsToFilter.AddIndex(row.Index) Link to comment Share on other sites More sharing options...
Hector Martinez 2 Posted December 5, 2019 Share Posted December 5, 2019 You could always just use this if you want to simplify your code .... rowSelection = myTable.Select([userCheck]"Yes" ) myTable.RemoveRows(rowSelection) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now