学习笔记192—python中使用h5py 读取.mat文件时报错“Unable to open file (file signature not found)”


python中使用h5py 读取.mat文件时报错:Unable to open file (file signature not found)

python读取matlab的mat文件失败

遇到BUG:

h5py OSError: Unable to open file (File signature not found)

一般python读取mat文件的语句是scipy.io.laodmat()

但是这次需要用h5py.File()读取,一直显示读取失败

后来找到是matlab制作mat文件有问题,例如下面这句话:

save('data.mat', 'name', 'age')

从scipy.io.laodmat()可以正常读取,但是使用h5py.File()就不行,显示签名失败。后来读了一下matlab的源代码说明,最后面要加一个version参数,该参数可以是‘-v4’,‘-v5’,‘-v6’,‘-v7’,‘-v7.3’

之后改为:

save('data.mat', 'name', 'age', '-v7.3')

就可以了。

参考链接:https://blog.csdn.net/lee18254290736/article/details/103417095


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM