Morio Saeki 3 Posted December 8, 2023 Share Posted December 8, 2023 ReplaceData() from Library folder in Spotfire server. --> FailReplaceData() from local folder. --> Success I use Spotfire Analyst Version 10.10.3 LTS HF-019 build version:10.10.2.33.[Replace Data file] : CSV file (ReplaceData() succes from local folder) : The CSV file was saved in the Library folder using Sopotfire'Analyst's export function.[ReplaceData() Result in my environment] - Replace using Data canvas from Library folder : Success - ReplaceData() using ironPython script from local folder : Success - Replacedata() using ironPython script from Library folder : fail csv filename = template1: cannot be opened. It may be damaged or in an unknown format. csv filename = template1_exported.csv: name 'filePath' is not defined[Test Script] - I only changed only filePath to match the test environment.----------------------------------------------------------------------------------------------------------import clrimport Spotfire.Dxp.Data.DataTablefrom Spotfire.Dxp.Data import *clr.AddReference("System.Windows.Forms")from System.Windows.Forms import OpenFileDialogfrom Spotfire.Dxp.Data import *myDataManager = Document.DatafilePath = "/User/saeki/template1" #cannot be opened. It may be damaged or in an unknown format.ds=myDataManager.CreateFileDataSource(filePath)table.ReplaceData(ds)---------------------------------------------------------------------------------------------------------- Link to comment Share on other sites More sharing options...
Gaia Paolini Posted December 11, 2023 Share Posted December 11, 2023 when you say a library folder, do you mean you are trying to access a csv file stored in the Spotfire library? Link to comment Share on other sites More sharing options...
Morio Saeki 3 Posted December 12, 2023 Author Share Posted December 12, 2023 Yes, I would like to ReplaceData() csv data from stored in the Spotfire library. Link to comment Share on other sites More sharing options...
Solution Gaia Paolini Posted December 12, 2023 Solution Share Posted December 12, 2023 Your csv data would be stored in the library as a sbdf. The way to retrieve something from the library is quite different. This code should work. Replace the path to your library path (excluding the word 'Library') ending with '/' and your file name in filePath accordingly. The variable table is an input parameter of type DataTable. from Spotfire.Dxp.Data import * from Spotfire.Dxp.Framework.Library import LibraryManager, LibraryItemType from Spotfire.Dxp.Data.Import import SbdfLibraryDataSource libraryPath ='/yourpath/' filePath = 'yourfile' manager = Application.GetService[LibraryManager]() (found, item) = manager.TryGetItem(libraryPath+filePath,LibraryItemType.SbdfDataFile) print(found) if found: ds = SbdfLibraryDataSource(item) table.ReplaceData(ds) Link to comment Share on other sites More sharing options...
Morio Saeki 3 Posted December 13, 2023 Author Share Posted December 13, 2023 Thank you for your information. I will try it. Link to comment Share on other sites More sharing options...
Morio Saeki 3 Posted December 14, 2023 Author Share Posted December 14, 2023 Thank you. I was able to ReplaceData() using the csv file in the Library area. 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