How do I read binary pickle data first, then unpickle it?
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Ancient Construction
--
Chapters
00:00 How Do I Read Binary Pickle Data First, Then Unpickle It?
00:54 Accepted Answer Score 8
01:15 Answer 2 Score 1
01:27 Thank you
--
Full question
https://stackoverflow.com/questions/2764...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #serialization #pickle
#avk47
    Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Ancient Construction
--
Chapters
00:00 How Do I Read Binary Pickle Data First, Then Unpickle It?
00:54 Accepted Answer Score 8
01:15 Answer 2 Score 1
01:27 Thank you
--
Full question
https://stackoverflow.com/questions/2764...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #serialization #pickle
#avk47
ACCEPTED ANSWER
Score 8
pickle.load(file) expects a file-like object. Instead, use:
Read a pickled object hierarchy from a string. Characters in the string past the pickled object’s representation are ignored.
ANSWER 2
Score 1
The documentation mentions StringIO, which I think is one possible solution.
Try:
f = open("big_networkx_graph.pickle","rb")
bin_data = f.read()
sio = StringIO(bin_data)
graph_data = pickle.load(sio)