Load spydata file

Viewed 10667

I'm coming from R + Rstudio. In RStudio, you can save objects to an .RData file using save()

save(object_to_save, file = "C:/path/where/RData/file/will/be/saved.RData")

You can then load() the objects :

load(file = "C:/path/where/RData/file/was/saved.RData")

I'm now using Spyder and Python3, and I was wondering if the same thing is possible.

I'm aware everything in the globalenv can be saved to a .spydata using this :

spyder save load spydata

But I'm looking for a way to save to a .spydata file in the code. Basically, just the code under the buttons.

Bonus points if the answer includes a way to save an object (or multiple objects) and not the whole env.

(Please note I'm not looking for an answer using pickle or shelve, but really something similar to R's load() and save().)

2 Answers

Considering the comment here, we can

  1. rename the file from .spydata to .tar
  2. extract the file (using file manager, for example). It will deliver a file .pickle (and maybe a .npy)
  3. extract the objects saved from the environment:

import pickle

with open(path, 'rb') as f:

    data_temp = pickle.load(f)
  1. that object will be a dictionary with the objects saved.
Related