Ankush Verma 2 Posted July 3, 2019 Share Posted July 3, 2019 Hello, I am trying to update the python script which works very well for one data dable. https://community.spotfire.com/wiki/how-replace-file-datasource-data-table-tibco-spotfirer-using-ironpython-scripting I want to check the source of the data table and want to replace the table source only if it is excel and would leave all other data tables. Thanks. Link to comment Share on other sites More sharing options...
Shandilya Peddi Posted July 3, 2019 Share Posted July 3, 2019 Check this article on how to retrieve data source information https://community.spotfire.com/wiki/how-use-ironpython-tibco-spotfirer-get-datatable-source-information Link to comment Share on other sites More sharing options...
Ankush Verma 2 Posted September 19, 2019 Author Share Posted September 19, 2019 Change the data source of multiple input tables Presteps - *Rename the data tables whose data source need to be changed to [input] data table Eg if table name is student rename it to [input] Student and leave others as it is. *Folder - Document property for giving the pathof the files to be replaced for eg if file is placed in the desktop then update the value to- //C:/Users/Desktop/ in the folder document property, I have added the input field next to the replace data source button. import clr clr.AddReference("System.Windows.Forms") from Spotfire.Dxp.Data.DataOperations import * from Spotfire.Dxp.Data import * from Spotfire.Dxp.Data import DataFlowBuilder # Search for the tables which need to be replaced and assign it to Tblnm (for eg only excel) for table in Document.Data.Tables: if(table.Name[1:6]=="Input"): Tblnm=table.Name[8:20] sourceView=table.GenerateSourceView() #get the dat table data source operation op=sourceView.GetAllOperations[DataSourceOperation]()[0]; #build the data flow for table in Document.Data.Tables: dataSource= Document.Data.CreateFileDataSource(Document.Properties["Folder"]+Tblnm+".xlsx"); dataFlow = DataFlowBuilder(dataSource, Application.ImportContext).Build(); #replace the data source if op.CanReplaceDataFlow(): op.ReplaceDataFlow(dataFlow) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now