Jump to content

Want to create a button that will automatically send data table visualization to Data File


Greg Mccrary

Recommended Posts

I have a case where I want to create a button, that once the user filters down to their desired population, they can then send those results to a Data File that can be used in another Spotfire app.

I see that you can manually do this with File > Export > Data to File....

Is there a way to do this automatically at the push of a button

Link to comment
Share on other sites

You can export a datatable to the Library in SDBF format using a Python Code or Even R-Script;

Python -

from Spotfire.Dxp.Framework.ApplicationModel import *

from Spotfire.Dxp.Framework.Library import LibraryManager, LibraryItemType, LibraryItem, LibraryItemRetrievalOption

import time

ps = Application.GetService[ProgressService]()

def execute():

try:

# subtask 1 - simulates an indeterminate step

ps.CurrentProgress.ExecuteSubtask("Loading Table To Library");

time.sleep(1) # do some work

UploadTable()

time.sleep(1) # do some work

ps.CurrentProgress.CheckCancel()

except: # user canceled

pass

def UploadTable():

dataTable = Document.Data.Tables[myTable]

folder = '/Folder/Folder/Folder/Folder/'

fileName = myFileName

fullPath = str(folder+fileName)

lm = Application.GetService(LibraryManager)

(foundFile, fileItem) = lm.TryGetItem(fullPath, LibraryItemType.SbdfDataFile, LibraryItemRetrievalOption.IncludeProperties)

(foundFolder, folderItem) = lm.TryGetItem(folder, LibraryItemType.Folder, LibraryItemRetrievalOption.IncludeProperties)

if foundFile:

dataTable.ExportDataToLibrary(fileItem, fileName)

print "File found and overwritten"

elif foundFolder:

dataTable.ExportDataToLibrary(folderItem, fileName)

print "File not found but folder exists, writing the SDBF file there"

else:

print "File or Path not found. Please review settings"

#Use the ps.ExecuteWithProgress if you'd like to view the processing dialog

#ps.ExecuteWithProgress("Progress title", "Progress description", execute)

UploadTable()

R Script -

https://docs.tibco.com/pub/enterprise-runtime-for-R/4.1.1/doc/html/Language_Reference/SpotfireData/exportDataToSBDF.html

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