mat73
Load MATLAB .mat 7.3 into Python native data types (via h5/hd5/hdf5/h5py)
What it is and what it does
mat73 fills a gap left by scipy.io.loadmat, which cannot read MATLAB 7.3 .mat files because they are stored as HDF5 containers. This library wraps h5py and numpy to parse those HDF5 files and reconstruct them as native Python dictionaries, with optional attribute-style access for struct members. It handles standard MATLAB datatypes (numeric arrays, strings, structs as lists of dicts, cells as nested lists, sparse matrices) and can selectively load only specified variables or subtrees to reduce memory overhead.
The package is straightforward to use—a single loadmat() call returns a dictionary—but is narrowly scoped: it only handles MATLAB 7.3 files, does not support proprietary MATLAB types, and cannot write .mat files back. It depends on h5py for HDF5 access and numpy for array representation, both widely available.
Use it for:
- Load simulation or experimental data saved from MATLAB into Python for analysis with scientific libraries.
- Extract specific variables from large .mat files without loading the entire file into memory using the only_include parameter.
- Migrate MATLAB-based workflows to Python by reading existing .mat archives as dictionaries.
- Access nested MATLAB struct hierarchies using Python attribute syntax for cleaner code.
- Convert MATLAB sparse matrices into scipy.sparse format for linear algebra operations in Python.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Loads MATLAB 7.3 .mat files (stored as HDF5) into Python dictionaries with support for struct attribute access and selective variable loading.
Yes, if you need to read MATLAB 7.3 .mat files in Python. The package is stable, has low install friction, and solves a specific problem scipy.io.loadmat does not. The GPLv3 copyleft license is a consideration for proprietary projects. The repository remains active with no known vulnerabilities.
Install
mat73 on PyPI
pip
pip install mat73uv
uv add mat73poetry
poetry add mat73Installing mat73
Before you install
Low friction install with two common dependencies (h5py, numpy). Repository is active with recent commits and moderate community engagement (177 stars).
License in practice
GPLv3 copyleft license means any derivative work or distribution must also be open source under GPLv3 terms—acceptable for internal tools or open projects, but restrictive for proprietary software.
Quickstart
pip install mat73
import mat73
data_dict = mat73.loadmat('data.mat')
struct = data_dict['structure']
var = struct[0].var1 # with use_attrdict=True
Requires a MATLAB 7.3 .mat file; older .mat versions are not supported by this library.
Verify before relying
- Whether the gap between last release (2024-07-24) and current date indicates active maintenance or dormancy despite recent repo commits.
- Performance characteristics when loading large .mat files or deeply nested structures.
- Completeness of support for all HDF5 structures that MATLAB 7.3 can generate.
Package facts
| License | GPL3 (copyleft) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — h5py, numpy |
| Maintenance | actively maintained — 751 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 77,877/month — #14,486 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mat73-0.65-py3-none-any.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
pymatreaderReads MATLAB .mat files in both legacy and…
permissive · top 15,000 on PyPI
h5pyh5py reads and writes HDF5 files from Python,…
permissive · top 1,000 on PyPI
hickleHickle serializes Python objects to HDF5 files…
unclear · top 15,000 on PyPI
h5netcdfh5netcdf reads and writes netCDF4 files using…
permissive · top 5,000 on PyPI
h5groveh5grove provides building blocks for serving…
permissive · top 15,000 on PyPI
asammdfasammdf parses, edits, and exports ASAM MDF…
copyleft · top 5,000 on PyPI
pymap3dConverts between geographic and 3-D coordinate…
permissive · top 15,000 on PyPI
hdf5pluginRegisters HDF5 compression filters (Blosc,…
unclear · top 15,000 on PyPI
netCDF4netcdf4 provides a Python interface to read,…
permissive · top 5,000 on PyPI
tablesPyTables provides an object-oriented interface…
permissive · top 5,000 on PyPI