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

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -