excelironpythonspotfire

Header format of imported excel files into Spotfire IronPython?


I have a script that writes multiple excel files and I am trying to have another script in Spotfire that creates visualizations from these files. I am getting a "Failed to execute data source query for data source" error, which I believe is due to the header format.

I have tried having my first script export the data in all sorts of alignments, but for some reason it doesn't work unless I manually go into each one and click some random formatting stuff for the headers.

I guess I could have my second script open and do some random formatting before trying to import, but is there a way the files could go straight from the first to second script?


Solution

  • I've solved the problem by creating sbdf files instead: https://support.tibco.com/s/article/How-to-export-python-data-frames-to-Spotfire-SBDF-files-from-external-python-engines

    I get a list of all generated files in the folder and import data:

    for file in filenames:
        page = Document.Pages.AddNew(os.path.basename(file))
    
        # data import
        name = os.path.basename(file)
        status, table = Document.Data.Tables.TryGetValue(name)
        ds = Document.Data.CreateFileDataSource(file)
        ds.IsPromptingAllowed=False
    
        if status:
            table.ReplaceData(ds)
        else:
            new = Document.Data.Tables.Add(name, ds)