reading v 7.3 mat file in python

后端 未结 8 1769
情书的邮戳
情书的邮戳 2020-12-02 09:16

I am trying to read a matlab file with the following code

import scipy.io
mat = scipy.io.loadmat(\'test.mat\')

and it gives me the followin

8条回答
  •  一向
    一向 (楼主)
    2020-12-02 09:29

    I had a look at this issue: https://github.com/h5py/h5py/issues/726. If you saved your mat file with -v7.3 option, you should generate the list of keys with (under Python 3.x):

    import h5py
    with h5py.File('test.mat', 'r') as file:
        print(list(file.keys()))
    

    In order to access the variable a for instance, you have to use the same trick:

    with h5py.File('test.mat', 'r') as file:
        a = list(file['a'])
    

提交回复
热议问题