This article explains how to access and organize the Spotfire Library in Spotfire® using IronPython Scripting
Introduction
The Spotfire Library is an online storage used by Spotfire to store analysis files and other data objects. It can be accessed from the script using the LibraryManager service. This example shows how to leverage the Library in Spotfire using IronPython scripting.
Note: Using the Library requires the server-connected version of the desktop client (Spotfire Analyst).
Examples
Search the Spotfire Library
# Search for a DXP in the Library service = app.GetService[LibraryManager]() var items = service.Search("title:myAnalysis item_type:dxp", LibraryItemRetrievalOption.IncludePath, LibraryItemRetrievalOption.IncludeProperties) for item in items: # Do something with the item here... guid = item.Id
Sometimes we already know the path and type of the item. Then we can retrieve it without a search. In this example we store a property set on the item in a Document Property.
Retrieve a Library item and read its properties
from Spotfire.Dxp.Framework.Library import LibraryManager, LibraryItemType, LibraryItem, LibraryItemRetrievalOption libraryManager = Application.GetService(LibraryManager) (found, item) = lm.TryGetItem('/myFolder/myAnalysis', LibraryItemType.Analysis, LibraryItemRetrievalOption.IncludeProperties) # Store the value in a document property if found: Document.Properties['ExportDescriptionProperty'] = item.Description
In the last example, we combine previous examples and load an SBDF file from the Library into the current analysis.
Load an SBDF saved in the Library
from Spotfire.Dxp.Framework.Library import LibraryManager, LibraryItemRetrievalOption from Spotfire.Dxp.Data.Import import SbdfLibraryDataSource from System import Guid manager = Application.GetService[LibraryManager]() # You will need the GUID to your SBDF file saved in library, see previous examples myGuid = Guid('7a154208-4774-4eeb-9f3e-a0d94943ce8c') # Search library with above GUID, if found replace the data table, else do nothing (found, item) = manager.TryGetItem(myGuid) if found: dataSource = SbdfLibraryDataSource(item) Document.Data.Tables.Add("new_table", dataSource)
References
Recommended Comments
There are no comments to display.