skillfed

mat73

Load MATLAB .mat 7.3 into Python native data types (via h5/hd5/hdf5/h5py)

mat73 v0.65 77.9K downloads/30d#14,486 on PyPI177
Copyleft license GPL3 Active released

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 mat73

uv

uv add mat73

poetry

poetry add mat73

Installing 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

License :: OSI Approved :: GNU General Public License v3 (GPLv3)Operating System :: OS IndependentProgramming Language :: Python :: 3

Tags

load matlab mat files pythonmatlab 7.3 hdf5 readerconvert mat to python dictmatlab struct to pythonhdf5 matlab file loadermat73 file parser
matlab-interopdata-loadinghdf5

More Scientific/Engineering packages