Jump to content
  • Find Data Table Dependencies in Document Visualizations


    This script provides a quick and efficient way to manage and optimize your Spotfire analyses by giving you a clear picture of your data table dependencies

    Introduction

    When working with complex Spotfire analyses, understanding how data tables are utilized across various visualizations can be crucial. This can help in optimizing the performance and ensuring that all data sources are being used effectively. Here’s a Python script that can help you identify which data tables are being used by the visualizations in your Spotfire document and where they are used.

    Understanding the Script

    The script provided below scans through the entire Spotfire document and lists all the data tables. It checks which tables are being utilized in visualizations and identifies their exact locations within the document. This can be particularly useful for cleaning up unused tables or for understanding the dependencies in your analysis.

    Key Features

    • Identify Data Table Usage: The script identifies which data tables are being used by visualizations, except for those used in calculated values on text areas.
    • Locate Dependencies: It details the locations (pages and visual titles) where each data table is used.
    • Highlight Unused Tables: It lists tables that are not being used in any visualization, helping in cleanup and optimization efforts.

     

     

    #Find Data Table Dependencies in Document Visualizations
    #Shows what DataTables are being used by which visualization except those used in calculated values on text areas.
    #This scirpt does not detect what datatables rely on tables from current analysis
    
    from Spotfire.Dxp.Application.Visuals import VisualContent, VisualTypeIdentifiers
    
    tables={}
    for t in Document.Data.Tables:
       tables[t.Name]=False
    
    locations = ""
    
    for page in Document.Pages:
     for visual in page.Visuals:
      if visual.TypeId != VisualTypeIdentifiers.HtmlTextArea:
       vis = visual.As[VisualContent]()
       dtrtype = str(type(vis.Data.DataTableReference))
       if(dtrtype)<>"<type 'NoneType'>":
        aTable = vis.Data.DataTableReference.Name
        aLocation = " -> ".join([aTable,page.Title,visual.Title])
        tables[aTable]=True
        locations += "\n\t" + aLocation
    
    
    
    print "Tables not being used:"
    for t in sorted(tables):
     if not tables[t]:print "\t",t
    
    print "\nTables being used:"
    for t in sorted(tables):
     if tables[t]:print "\t",t
    
    
    print "\nTables in used by:"
    print locations

    How to Use the Script

    1. Copy and Paste: Copy the script and paste it into the Spotfire Script Editor.
    2. Run the Script: Execute the script to get a detailed report of the data table usage.
    3. Analyze the Output: Use the output to identify unused tables and understand where and how your data tables are being utilized.

    Sample Output

    Tables not being used:
        UnusedTable1
        UnusedTable2
    
    Tables being used:
        SalesData
        CustomerData
        ProductData
        InventoryData
    
    Tables in use by:
        SalesData -> Dashboard -> Sales Overview
        SalesData -> Dashboard -> Monthly Sales Trends
        CustomerData -> Customer Analysis -> Customer Demographics
        CustomerData -> Customer Analysis -> Customer Spending Patterns
        ProductData -> Product Performance -> Top Selling Products
        ProductData -> Product Performance -> Product Sales Trends
        InventoryData -> Inventory Management -> Current Stock Levels
        InventoryData -> Inventory Management -> Stock Replenishment Rates
    

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...