Mohd faizal Adris Posted October 13, 2020 Share Posted October 13, 2020 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 More sharing options...
Mohd faizal Adris Posted October 15, 2020 Author Share Posted October 15, 2020 This pieces of code helped me to solve the problem; for table in Document.Data.Tables: if table.Name=="CrossTableOH1": Document.Data.Tables.Remove("CrossTableOH1") Link to comment Share on other sites More sharing options...
Eric Lim 2 Posted October 16, 2020 Share Posted October 16, 2020 the temp file is still written as inconsitent name 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