matlab – reading v 7.3 mat file in python

matlab – reading v 7.3 mat file in python

Try using h5py module

import h5py
with h5py.File(test.mat, r) as f:
    f.keys()

Ive created a small library to load MATLAB 7.3 files:

pip install mat73

To load a .mat 7.3 into Python as a dictionary:

import mat73
data_dict = mat73.loadmat(data.mat)

simple as that!

matlab – reading v 7.3 mat file in python

import h5py
import numpy as np
filepath = /path/to/data.mat
arrays = {}
f = h5py.File(filepath)
for k, v in f.items():
    arrays[k] = np.array(v)

you should end up with your data in the arrays dict, unless you have MATLAB structures, I suspect. Hope it helps!

Leave a Reply

Your email address will not be published. Required fields are marked *