{"id":24014,"library":"mat73","title":"mat73","description":"Load MATLAB .mat v7.3 files into Python native data types via h5py. Version 0.65, stable release with support for sparse matrices, cell arrays, and selective variable loading.","status":"active","version":"0.65","language":"python","source_language":"en","source_url":"https://github.com/skjerns/mat7.3","tags":["matlab","hdf5","h5py","mat73","data loading"],"install":[{"cmd":"pip install mat73","lang":"bash","label":"latest PyPI"}],"dependencies":[{"reason":"Required to read HDF5-format .mat files","package":"h5py","optional":false},{"reason":"Data arrays are returned as numpy arrays","package":"numpy","optional":false},{"reason":"Sparse matrices require scipy.sparse","package":"scipy","optional":true}],"imports":[{"note":"Common mistake: mat73 does not expose loadmat as a top-level function; use mat73.loadmat() or from mat73 import loadmat (which works but is less conventional).","wrong":"from mat73 import loadmat","symbol":"mat73","correct":"import mat73"}],"quickstart":{"code":"import mat73\nimport numpy as np\n\ndata = mat73.loadmat('test.mat')\nprint(data.keys()) # list variables","lang":"python","description":"Load a .mat v7.3 file and inspect variable names."},"warnings":[{"fix":"Upgrade to >=0.60 and manually strip nulls if needed: s.split('\\x00')[0]","message":"Version 0.60 removed automatic null-character stripping from strings; strings now keep null characters.","severity":"breaking","affected_versions":"<0.60"},{"fix":"Upgrade to >=0.63 for correct sparse matrix support.","message":"Version 0.63 fixed sparse matrix bug #51; previously sparse loading could crash or produce incorrect results.","severity":"breaking","affected_versions":"<0.63"},{"fix":"Use Python >=3.9.","message":"Python 3.8 support is dropped as of version 0.64; no warning emitted but installation may fail.","severity":"deprecated","affected_versions":">=0.64"},{"fix":"Verify your .mat file is v7.3 by checking if h5py can open it, or use scipy.io.loadmat for older formats.","message":"The library only supports MATLAB v7.3 files (HDF5-based). It will silently fail or produce garbage on older .mat formats.","severity":"gotcha","affected_versions":"all"},{"fix":"In >=0.65, use mat73.loadmat('file.mat', squeeze=False) to preserve dimensions.","message":"By default, mat73.loadmat squeezes singleton dimensions of arrays. This can remove dimensions unintentionally.","severity":"gotcha","affected_versions":"<=0.64"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use scipy.io.loadmat for legacy .mat files, or convert the file to v7.3 in MATLAB.","cause":"The file is not a valid MATLAB v7.3 file (e.g., it's an older format).","error":"KeyError: 'MATLAB_class'"},{"fix":"Check the file path and ensure the file exists.","cause":"File path is incorrect or file does not exist.","error":"OSError: Unable to open file (unable to open file: name = 'file.mat', errno = 2, error message = 'No such file or directory')"},{"fix":"Pass a string path or a file-like object opened in binary mode.","cause":"loadmat expects a file path string or file-like object; passing an unsupported type.","error":"TypeError: expected str, bytes or os.PathLike object, not ..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}