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

相关文章:

  • 2021-09-20
  • 2022-12-23
  • 2021-10-17
  • 2021-12-05
  • 2021-07-31
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-05
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-06-19
  • 2021-10-19
  • 2022-12-23
相关资源
相似解决方案