Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In matlab, how to read python pickle file?

Tags:

python

matlab

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.

like image 302
Z Cao Avatar asked Sep 16 '14 02:09

Z Cao


Video Answer


1 Answers

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.

like image 59
Z Cao Avatar answered Sep 20 '22 15:09

Z Cao