Registry / data / pymatreader

pymatreader

JSON →
library1.2.3pypypi✓ verified 86d ago

A convenient reader for MATLAB .mat files, handling various data types and structures. Current version 1.2.2, requires Python ≥3.10. Regular updates.

pip install pymatreader
INSTALL
IMPORT
SIG · PYMATREADER
P
pymatreader
datapythonv1.2.3
Install
7.8s avg
Import
1106ms
Disk
246MB
Pass rate
9/ 10
Env Coverage9 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 7.5s
py 3.11
✓ —
✓ 7.6s
py 3.12
✓ —
✓ 7.8s
py 3.13
✓ —
✓ 7.6s
py 3.9
✕ build_error
✓ 8.4s
246MB installed
● package 246MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

read_mat
from pymatreader import read_mat
Correct usage.

Basic usage to read a .mat file and access its variables.

from pymatreader import read_mat import os # Read a MATLAB .mat file data = read_mat('example.mat') # Access variables by name # data.variable_name print(data.keys())
Debug
Known issues
gotchaBy default, pymatreader returns variables as attributes of a simple namespace object. If you expect a dict, use `ignore_fields=False` or access via `data['varname']`.
fix
Use `data['varname']` or set `ignore_fields=True` (default) to get attribute-style access.
affects: all
breakingpymatreader 1.0+ dropped support for Python 2 and Python <3.10. The API changed from returning dicts to returning a namespace object.
fix
Use `data = read_mat('file.mat').__dict__` to get a dict, or update code to use attribute access.
affects: >=1.0
deprecatedThe `matfile` function is deprecated in favor of `read_mat`.
fix
Replace `from pymatreader import matfile` with `from pymatreader import read_mat`.
affects: >=0.4
Errors
Common errors & fixes
AttributeError: 'Namespace' object has no attribute '...'
Accessing a variable by name that doesn't exist in the .mat file, or using wrong case.
fix
List available keys: `print(data.keys())` and then access the correct key.
ValueError: Unknown mat file type, version ...
File might be corrupted or unsupported format (e.g., MATLAB v4).
fix
Try opening with scipy.io.loadmat as fallback, or check file integrity.
ModuleNotFoundError: No module named 'h5py'
Trying to read a v7.3 file without h5py installed.
fix
Install h5py: `pip install h5py`.
Upgrade
Version history
1.2.3latest on PyPI · released May 4, 2026
Audit
Dependencies
h5pyrequiredRequired for reading MATLAB v7.3 files (HDF5 format)
scipyrequiredUsed as fallback for older .mat files
Agent activity
11 hits · last 30 days
node
10
Resources
pymatreader — pip install pymatreader · libregistry