Jump to content

Delete and re-create data table from Cross Table using IronPython


Mohd faizal Adris

Recommended Posts

I have managed tocreate a new data tablefrom Cross Table visualization using IronPython script and use it for further analysis.This newly data table are required to be updated at a fixregular intervals.

Is there any API that allows me to delete and re-create the "CrossTableGT" data table without manually delete it from data canvas

Any helps is much appreciated!

from System.IO import Path, File, StreamWriter

from Spotfire.Dxp.Data import DataTableSaveSettings

from Spotfire.Dxp.Application.Visuals import CrossTablePlot

from Spotfire.Dxp.Data.Import import TextFileDataSource

from Spotfire.Dxp.Data.Import import TextDataReaderSettings

from Spotfire.Dxp.Application.Visuals import TablePlot

from Spotfire.Dxp.Application.Visuals import VisualTypeIdentifiers

 

#Temp file for storing the cross table data

tempFolder = Path.GetTempPath()

tempFilename = Path.GetTempFileName()

 

#Export CrossTable data to the temp file

writer = StreamWriter(tempFilename)

crossTable.As[CrossTablePlot]().ExportText(writer)

 

#Add tempfile back into Spotfire using TextFileDataSource

readerSet = TextDataReaderSettings()

readerSet.Separator = "t"

readerSet.AddColumnNameRow(0)

textDataSource = TextFileDataSource(tempFilename, readerSet )

myNewTable = Document.Data.Tables.Add("CrossTableGT",textDataSource)

#Document.Data.Tables["CrossTableGT"].ReloadAllData()

 

#If you want to change the data table to be embedded and not linked, use the following code

settings = DataTableSaveSettings (myNewTable,False, True);

Document.Data.SaveSettings.DataTableSettings.Add(settings);

Link to comment
Share on other sites

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...