Search code examples
pythonpicklespotfirespotfire-analyst

Spotfire : Load already created pickle file from data function in spotfire


Has anyone tried calling in a pickle file already created from spotfire's data function? There is too little information about using pickle file from data function. If anyone has used it, please provide a simple example of calling the pickle file from the path of the local pc and using it.

I searched spotfire pickle on Google and tried the results but failed. I'd like to refer to an example.


Solution

  • You can do it from within a Spotfire Python data function as you would normally in Python, there is nothing special about it, unless you do not have access to the file system where your pickle file is. So something like the following should work:

    import pickle
    filename = "your file path"
    with open(filename, 'rb') as f: 
        mydata = pickle.load(f)
    

    where 'your file path' is the path to the pickle file. If you know the names of variables in your pickle file, you can put them in a comma separated list instead of mydata.