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]()
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

No comments: