all datatables in iron pyython

Solutions on MaxInterview for all datatables in iron pyython by the best coders in the world

showing results for - "all datatables in iron pyython"
Oswald
28 Feb 2018
1from Spotfire.Dxp.Data.DataOperations import DataSourceOperation
2from Spotfire.Dxp.Application import DocumentMetadata
3from Spotfire.Dxp.Data.DataOperations import DataOperation
4from Spotfire.Dxp.Application.Visuals import HtmlTextArea
5from Spotfire.Dxp.Framework.Library import LibraryManager, LibraryItemType, LibraryItem, LibraryItemRetrievalOption
6lm = Application.GetService(LibraryManager)
7from System import Guid
8
9#Function to write the tablename, its type and location in an html table for readability.
10def writeHtml(tableName,type,path):
11 global html
12 html=html+"<tr><td>"+tableName+"</td><td>"+type+"</td><td>"+path+"</td></tr>"
13
14html="<table border=1><tr style='text-align:center'><th>Data Table</th><th>Type</th><th>Source</th></tr>"
15
16for tbl in Document.Data.Tables:
17 sourceView = tbl.GenerateSourceView();
18 op=sourceView.GetAllOperations[DataOperation]()
19
20 #DataSourceOperation corresponds to tables created via copying content from Clipboard,Informationlinks,Text Files & SBDF/STDF files
21 if type(op[0]).__name__ == 'DataSourceOperation':
22  t=op[0].GetDataFlow().DataSource
23  if(type(t).__name__  == "InformationLinkDataSource"):
24   found=t.FindAll("id::"+str(t.Id))
25   writeHtml(tbl.Name,type(t).__name__,found.First.Path)
26  if(type(t).__name__  == "TextFileDataSource" or type(t).__name__  == "Excel2FileDataSource"):
27   if (t.FilePath == None):
28    path="Clipboard"
29   else:
30    path=t.FilePath
31   writeHtml(tbl.Name,type(t).__name__,path)
32  if(type(t).__name__ == "DatabaseDataSource"):
33    writeHtml(tbl.Name,type(t).__name__,t.Settings.Provider)
34  if(type(t).__name__  == "StdfFileDataSource" or type(t).__name__  == "SbdfFileDataSource"):
35    writeHtml(tbl.Name,type(t).__name__,t.FilePath)
36  if(type(t).__name__  == "SbdfLibraryDataSource"):
37   l = lm.Search(t.Name, LibraryItemRetrievalOption.IncludePath)
38   for item in l:
39    writeHtml(tbl.Name,type(t).__name__,item.Path)
40
41 #DataConnectionOperation corresponds to using data connections (connectors)
42 elif(type(op[0]).__name__ == "DataConnectionOperation"):
43   writeHtml(tbl.Name,type(op[0]).__name__,op[0].DisplayName)
44
45 #DataTableDataSourceOperation corresponds to datatables added using existing tables
46 elif(type(op[0]).__name__ == "DataTableDataSourceOperation"):
47   writeHtml(tbl.Name,type(op[0]).__name__,op[0].DataTable.Name)
48
49 #DataFunctionOperation corresponds to datatable added via Data Function
50 elif (type(op[0]).__name__ == "DataFunctionOperation"):  
51  t=op[0].DataFunction   
52  sourceType= t.DataFunctionDefinition.ServiceType.DisplayName   
53  writeHtml(tbl.Name,sourceType,op[0].DisplayName)
54 
55 html=html+"</table>"
56 myTextArea.As[HtmlTextArea]().HtmlContent=html
57
58
59myTextArea - script parameter referring to a Textarea visualization which will be populated with the source information for all the data tables in 
60the current dxp.
61
similar questions
queries leading to this page
all datatables in iron pyython