简体   繁体   中英

In matlab, how to read python pickle file?

In python, I generated a .p data file by

pickle.dump( allData, open( "myallData.p", "wb" ))

Now I want to read myallData.p in Matlab. (My Matlab is installed under Windows 8, which does not have python in it.) Any ideas? Thanks in advance.

I ended up with read the data back from the .p file:

[whatever_data]=pickle.load( open( "myallData.p", "rb" ) )

Then use scipy to convert and save the data to .mat

import numpy, scipy.io
scipy.io.savemat('/home/myfiles/mydata.mat', mdict={'whatever_data': whatever_data})

So as to avoid dealing with pickle.

matlab and python pickle do not use the same format. You can use this writeup to format the data in a way matlab can understand.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM