【发布时间】:2021-12-14 17:49:13
【问题描述】:
我看到这个问题没有任何明确的答案,例如here。我有.mat 数据从不同的数据结构转换而来,并尝试使用scipy.io.loadmat 在python 中加载它。对于某些文件,这种方法可以正常工作,但对于其他文件,我会收到此错误:
mat = sio.loadmat(i, verify_compressed_data_integrity=False)
File "/Users/aeglick/opt/anaconda3/lib/python3.8/site-packages/scipy-1.7.1-py3.8-macosx-10.9-x86_64.egg/scipy/io/matlab/mio.py", line 226, in loadmat
matfile_dict = MR.get_variables(variable_names)
File "/Users/aeglick/opt/anaconda3/lib/python3.8/site-packages/scipy-1.7.1-py3.8-macosx-10.9-x86_64.egg/scipy/io/matlab/mio4.py", line 390, in get_variables
hdr, next_position = self.read_var_header()
File "/Users/aeglick/opt/anaconda3/lib/python3.8/site-packages/scipy-1.7.1-py3.8-macosx-10.9-x86_64.egg/scipy/io/matlab/mio4.py", line 346, in read_var_header
hdr = self._matrix_reader.read_header()
File "/Users/aeglick/opt/anaconda3/lib/python3.8/site-packages/scipy-1.7.1-py3.8-macosx-10.9-x86_64.egg/scipy/io/matlab/mio4.py", line 108, in read_header
raise ValueError('Mat 4 mopt wrong format, byteswapping problem?')
ValueError: Mat 4 mopt wrong format, byteswapping problem?
我不确定是什么导致了这个问题。我每次都以相同的方式保存.mat 文件,因此它们都应该是可读的。我也尝试了h5py 并得到了类似的错误。关于如何读取我的数据文件有什么建议吗?
【问题讨论】: