pandas - How do I decode a msgpack file in Python? -
i've created msgpack file pandas dataframe, using following code:
df.to_msgpack('ixto.msg')
i've confirmed file saved in directory, can't use msgpack library python since following code:
unp = msgpack.unpackb('ixto.msg')
gives me following error:
attributeerror: 'str' object has no attribute 'read'
msgpack.unpackb
expects bytes (thus "b") containing encoded data, , you're giving name of file containing data.
so need read file first :
with open('ixto.msg', 'rb') f: unp = msgpack.unpackb(f.read())
Comments
Post a Comment