Jump to content
We've recently updated our Privacy Statement, available here. ×
  • How to Export Table/Cross Table visualization data to SBDF file in Spotfire library using Spotfire® Using IronPython Scripting


    Export Table/Cross Table visualization data (in memory or in database) in library SBDF file, conditional export can also be achieved by adding conditions to visualizations and then exporting it in SBDF format.

    Introduction

    Export Table/Cross Table visualization data (in memory or in database) in library SBDF file, conditional export can also be achieved by adding conditions to visualizations and then exporting it in SBDF format.

    Code Sample

    # Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    
    from System.IO import *
    from Spotfire.Dxp.Application.Visuals import VisualContent
    from System import Array,Guid,String,Object
    from Spotfire.Dxp.Data.Import import *
    from Spotfire.Dxp.Framework.Library import LibraryManager, LibraryItemRetrievalOption, LibraryItemType, LibraryItem
    
    vc=Visuals.As[VisualContent]()  #Visuals = Script parameter for Table/Cross Table visualization
    memStream = MemoryStream();
    sWriter = StreamWriter(memStream);
    #Exporting the data to Memory Stream
    vc.ExportText(sWriter);  #exports data in tab separated text
    sReader = StreamReader(memStream);
    memStream.Seek(0, SeekOrigin.Begin);
    
    textDataSource = TextFileDataSource(memStream);
    tables = Document.Data.Tables["ExportData"] # Create dummy exportdata datatable and have the rows in visualization be exported to that table
    tables.ReplaceData(textDataSource)
    
    # uploadFile: the file name to write in the library
    # libraryFolder: the full path to the folder to write to in the library
    # sourceData: the data table in the analysis to export out
    
    libraryManager = Application.GetService[LibraryManager]()
    libraryFolder = "/SBDF"
    
    uploadFile= tables.Name	
    sourceData= tables.Name	
    items = libraryManager.Search("type:SBDF and title:"+uploadFile,LibraryItemRetrievalOption.IncludePath)
    
    if (items.Count > 0): 
    	tables.ExportDataToLibrary(items[0], uploadFile)
    else:
    ## File Not Found, Searching for Folder to Create File In
    	items = libraryManager.Search("type:folder",LibraryItemRetrievalOption.IncludePath)
    	for item in items: 
    		if (libraryFolder == item.Path):
    			tables.ExportDataToLibrary(item, uploadFile)
     

    References

    License:   TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...