本文介绍了在Matlab中,如何读取python pickle文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在python中,我通过生成一个.p数据文件
In python, I generated a .p data file by
pickle.dump( allData, open( "myallData.p", "wb" ))
现在,我想在Matlab中阅读myallData.p. (我的Matlab安装在Windows 8下,但其中没有python.)有什么想法吗?预先感谢.
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.
推荐答案
我最终从.p文件中读取了数据:
I ended up with read the data back from the .p file:
[whatever_data]=pickle.load( open( "myallData.p", "rb" ) )
然后使用scipy将数据转换并保存到.mat
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})
为避免与泡菜打交道.
这篇关于在Matlab中,如何读取python pickle文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!