Jump to content

handling exception in Spotfire python script

Ankush Verma 2

Recommended Posts

#I am trying to replace multiple files in Spotfire using a python script, script works perfectly well when it finds all the files in the destination folder, however, if even a single file is not present in the destination folder then it gives an alert that "file XYZ.xlsx is not found in the destination folder" and the code will not replace a single file.

#Below is the code which works if all the files are found in the destination folder:

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 theTblnm

for table in Document.Data.Tables:





dataSource= Document.Data.CreateFileDataSource(Document.Properties["Folder"]+Tblnm+".xlsx);

dataFlow = DataFlowBuilder(dataSource, Application.ImportContext).Build();

if op.CanReplaceDataFlow():



#I have tried the below code it works in the python window but crashes the .dxp when I openthe data table property.


if op.CanReplaceDataFlow():




Link to comment
Share on other sites

Hi Rayees,

Thanks for looking into this, I am using version 7.11.

I have used:

import clr


and after removing this part, Spotfire is not crashing anymore, however, the code is still not replacing the data source of the files available in a folder.can you help

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...