It is possible to manage data tables via the API with IronPython scripting. This example demonstrates how to create a new data table based on a data table already existing in the analysis file. If the new data table already exists, then the new table will instead be replaced.
Introduction
It is possible to manage data tables via the API with IronPython scripting. This example demonstrates how to create a new data table based on a data table already existing in the analysis file. If the new data table already exists, then the new table will instead be replaced.
Example
from Spotfire.Dxp.Data import * from Spotfire.Dxp.Data.Import import DataTableDataSource #Define new table name newTableName = 'myNewDataTableName' #Define the source table, pass as an input parameter called sourceTable dataTableDataSource = DataTableDataSource(sourceTable) #Function to return a Spotfire Data Table. Will return None if the data table does not exist #parameter: tableName - the name of the data table in the Spotfire document def getDataTable(tableName): try: return Document.Data.Tables[tableName] except: print ("Cannot find data table: " + tableName + ". Returning None") return None #Check if new table already exists dt = getDataTable(newTableName) if dt != None: #If exists, replace it dt.ReplaceData(dataTableDataSource) else: #If it does not exist, create new Document.Data.Tables.Add(newTableName, dataTableDataSource)
References
Recommended Comments
There are no comments to display.