Unable to load pickle file
<p>I was previously able to load a pickle file. I saved a new file under a different name. I am unable to load either the old or the new file. Which is a bummer as it contains data which I have worked hard to scrub.</p>

<p>Here is the code that I use to save:</p>

<pre><code>def pickleStore():
    pickle.dump(store, open("...shelf3.p", "wb"))
</code></pre>

<p>Here is the code that I use to re-load:</p>

<pre><code>def pickleLoad():
    store = pickle.load(open(".../shelf3.p","rb" ) )
</code></pre>

<p>The created file exists, and I run pickleLoad() no errors come up, neither does any variables show in the panel variable explorer. If I try to load a non-existent file, I get a error message. </p>

<p>I am running spyder, python 3.5.</p>

<p>Any suggestions?    </p>

<p>As a general and more versatile approach I would suggest something like this:</p>

<pre><code>def load(file_name):
    with open(simulation, 'rb') as pickle_file:
        return pickle.load(pickle_file)

def save(file_name, data):
    with open(file_name, 'wb') as f:
        pickle.dump(data, f)
</code></pre>

<p>I have added this snippet to several projects in order to reduce rewriting same code several times.</p>

python pickle