Remove (Or Keep) Rows Based on Cell Data from a Column in TIBCO Spotfire® Using IronPython Scripting

By:
Last updated:
7:20am Dec 03, 2019
Back to main IronPython scripting page

Introduction

This script will remove (or keep) rows based on cell data from a column. If the cell value of the column equals 'Unknow' the row will be removed. The comparison '==' could be inverted to instead keep the rows marked 'Unknown'.

Code Sample



#Remove (or keep) rows based on cell data of a row
from Spotfire.Dxp.Data import DataValueCursor,RowSelection,IndexSet

# Add a reference to the data table in the script.
dataTable = Document.Data.Tables["Data Table"]
# Reference to the Column of the Table
dataValuesCursor=DataValueCursor.CreateFormatted(dataTable.Columns["Origin"])
rowsToRemove=IndexSet(dataTable.RowCount,False)

for row in dataTable.GetRows(dataValuesCursor):
  #Statement to remove or keep rows.
  if dataValuesCursor.CurrentValue=="Unknown":
    rowsToRemove.AddIndex(row.Index)

dataTable.RemoveRows(RowSelection(rowsToRemove))



 

References

 

License:  TIBCO BSD-Style License