{"id":24354,"library":"pymatreader","title":"PyMatReader","description":"A convenient reader for MATLAB .mat files, handling various data types and structures. Current version 1.2.2, requires Python ≥3.10. Regular updates.","status":"active","version":"1.2.2","language":"python","source_language":"en","source_url":"https://gitlab.com/obrizum/pymatreader","tags":["matlab","mat-file","reader","scientific"],"install":[{"cmd":"pip install pymatreader","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for reading MATLAB v7.3 files (HDF5 format)","package":"h5py","optional":false},{"reason":"Used as fallback for older .mat files","package":"scipy","optional":false}],"imports":[{"note":"Correct usage.","wrong":"","symbol":"read_mat","correct":"from pymatreader import read_mat"}],"quickstart":{"code":"from pymatreader import read_mat\nimport os\n\n# Read a MATLAB .mat file\ndata = read_mat('example.mat')\n# Access variables by name\n# data.variable_name\nprint(data.keys())","lang":"python","description":"Basic usage to read a .mat file and access its variables."},"warnings":[{"fix":"Use `data['varname']` or set `ignore_fields=True` (default) to get attribute-style access.","message":"By 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']`.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `data = read_mat('file.mat').__dict__` to get a dict, or update code to use attribute access.","message":"pymatreader 1.0+ dropped support for Python 2 and Python <3.10. The API changed from returning dicts to returning a namespace object.","severity":"breaking","affected_versions":">=1.0"},{"fix":"Replace `from pymatreader import matfile` with `from pymatreader import read_mat`.","message":"The `matfile` function is deprecated in favor of `read_mat`.","severity":"deprecated","affected_versions":">=0.4"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"List available keys: `print(data.keys())` and then access the correct key.","cause":"Accessing a variable by name that doesn't exist in the .mat file, or using wrong case.","error":"AttributeError: 'Namespace' object has no attribute '...'"},{"fix":"Try opening with scipy.io.loadmat as fallback, or check file integrity.","cause":"File might be corrupted or unsupported format (e.g., MATLAB v4).","error":"ValueError: Unknown mat file type, version ..."},{"fix":"Install h5py: `pip install h5py`.","cause":"Trying to read a v7.3 file without h5py installed.","error":"ModuleNotFoundError: No module named 'h5py'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}