I realize a form of this question has already been asked several times on Stackoverflow but it really seems like this situation is different.
I cannot open a pickled file due to an EOFError
but the file is certainly not empty since it 25 megs large. Further, I find it almost impossible that there is something fundamentally wrong with the file.
I have been using pickles extensively over the last 7 years and it's been roughly 3 years since I last encountered this error. Second, when I last saved the file I had two other pickles of basically the same form and I saved them in the same way and they are working fine.
I saved the file in the following manner:
import pickle
temp = open(name, "wb")
pickle.dump(obj, temp)
temp.close()
Where name
is the file name and obj
is the thing I saved. When I open it with this code:
pkl_file = open(name, 'rb')
obj = pickle.load(pkl_file)
pkl_file.close()
I get the EOFError
. The thread here seems to have the most information. But part of their code they're using has the line:
num_cars = pickle.load(car_file)
Which will throw the EOFError
in my case. I need to know if there is some different way to open the pickled file and get access to the info stored in it. The info is certainly there as it is composed of 25 megs. I'm also using Python 3.8.0
. Thanks.