Command to Load .spydata file

10,167 views
Skip to first unread message

Raymond Phillips

unread,
Jan 7, 2014, 11:22:35 AM1/7/14
to spyd...@googlegroups.com
Hi All,

I'm pretty new to Spyder, having recently decided to migrate to it from MATLAB for my MSc research. I have a question regarding importing data.

I'm aware of the interactive importing you can do in Spyder however, I was wandering if there is a line of code for importing a spydata file into the workspace as well. In MATLAB this would just be something like "load myData.mat"

Thanks,

Ray

David Verelst

unread,
Jan 11, 2014, 1:06:28 PM1/11/14
to spyder

Hi,

I never used this function, but I think you have a good point here. It couldn’t find any documentation regarding this .spydata file format, and it might as well be described how to use it using both the GUI and a script (maybe a public spyder function of some sort can be used/created for this?). This is what I figured out: it is tarfile containing some (only 1?) pickled python dictionary containing the workspace variables.

As a small example, this is how you can load a *.spydata file (based on load_dictionary() in spyderlib/utils/iofuncs.py):

# a naive and incomplete demonstration on how to read a *.spydata file import pickle import tarfile # open a .spydata file filename = 'test.spydata' tar = tarfile.open(filename, "r") # extract all pickled files to the current working directory tar.extractall() extracted_files = tar.getnames() for f in extracted_files: if f.endswith('.pickle'): with open(f, 'rb') as fdesc: data = pickle.loads(fdesc.read()) # or use the spyder function directly: from spyderlib.utils.iofuncs import load_dictionary data_dict = load_dictionary(filename)

I went ahead and created an issue for this here: http://code.google.com/p/spyderlib/issues/detail?id=1693

Regards,

David

--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To post to this group, send email to spyd...@googlegroups.com.
Visit this group at http://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/groups/opt_out.

Carlos Córdoba

unread,
Jan 13, 2014, 11:57:04 AM1/13/14
to spyd...@googlegroups.com
Thanks David for going deeper with this one. I think we should change to use dill

https://github.com/uqfoundation/dill

instead of using pickle because dill is able to pickle (almost) any Python object whereas pickle is quite limited. Another thing to do for 2.4 :-)

Cheers,
Carlos

El 11/01/14 13:06, David Verelst escribió:

Raymond Phillips

unread,
Jan 20, 2014, 6:48:55 AM1/20/14
to spyd...@googlegroups.com
Thanks for taking a look at this David.

I will try do something similar using the script that you provided.

I'll keep an eye out for any integrated support that Spyder may have for this in the future.

Thanks again,

Ray

Adrian Zambrano

unread,
Apr 16, 2015, 9:45:35 AM4/16/15
to spyd...@googlegroups.com
Hello, 

I've been searching also for this. I was using matlab before and it was convenient not having to recompute everything again. so far I'm working more with dictionaries, I save/work with a few dictionaries during my python sesion then I save dictionary in a mat file, then it is easy to recover for next time, although most variables will be decleare again but at least I save results from computations so i do not have to re-compute. But yes I agree with you, it'd be a very useful feature since pickles or h5 do not always work for me.

best

Stevem

unread,
Sep 12, 2016, 11:27:33 AM9/12/16
to spyder
This should be added, very useful !

Carlos Córdoba

unread,
Sep 12, 2016, 11:28:48 AM9/12/16
to spyd...@googlegroups.com
Hi,

We're working to load spydata files automatically in a future version (not Spyder 3.0 :-)


Cheers,
Carlos

El 07/09/16 a las 15:31, Stevem escribió:
--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To post to this group, send email to spyd...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages