{"id":21555,"library":"mat-io","title":"mat-io","description":"A modern Python library for reading and writing MATLAB .mat files (v7 and v7.3 formats) with native support for MATLAB datatypes like table, string, datetime, struct, and cell. Version 0.7.1 runs on Python ≥3.11. Development is active, with regular releases.","status":"active","version":"0.7.1","language":"python","source_language":"en","source_url":"https://github.com/foreverallama/matio","tags":["matlab",".mat","file-io","data-science"],"install":[{"cmd":"pip install mat-io","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for array data handling","package":"numpy","optional":false},{"reason":"Required for v7.3 HDF5-based files","package":"h5py","optional":true}],"imports":[{"note":"Public API is at top-level","wrong":"from matio.reader import MatFileReader","symbol":"MatFileReader","correct":"from matio import MatFileReader"},{"note":"Public API is at top-level","wrong":"from matio.writer import MatFileWriter","symbol":"MatFileWriter","correct":"from matio import MatFileWriter"},{"note":"","wrong":"","symbol":"MatObject","correct":"from matio import MatObject"}],"quickstart":{"code":"from matio import MatFileReader\nimport os\n\nfilename = 'example.mat'\nif os.path.exists(filename):\n    reader = MatFileReader(filename)\n    data = reader.read()\n    print(data.keys())\nelse:\n    print('File not found.')","lang":"python","description":"Load a .mat file and print variable names."},"warnings":[{"fix":"Upgrade Python to 3.11 or later.","message":"Python >=3.11 required; no support for older Python versions.","severity":"breaking","affected_versions":"<0.5.0 or Python<3.11"},{"fix":"Use missing strings or convert NaN to empty strings before saving.","message":"MATLAB string arrays containing NaN are not supported in write operations (v0.5.2+).","severity":"gotcha","affected_versions":">=0.5.2"},{"fix":"Use mat-io's MatFileReader for proper table/string support.","message":"The old scipy.io.loadmat is not a drop-in replacement; mat-io has different API and handles newer MATLAB types.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"pip install mat-io, then import matio.","cause":"Installed package is 'mat-io' (hyphen), but imported as 'matio' (no hyphen). The package name on PyPI uses hyphen, but the import uses underscore? Actually the import is 'matio' as per docs.","error":"ModuleNotFoundError: No module named 'matio'"},{"fix":"Resave the .mat file in MATLAB using v7 or v7.3 format.","cause":"Attempting to read a .mat file from an unsupported older MATLAB version or a corrupt file.","error":"matio.MatioError: Unsupported MATLAB version"},{"fix":"Convert data to supported types: numeric, string, cell, struct.","cause":"Attempting to write unsupported data types (e.g., object arrays, structured arrays with non-numeric fields).","error":"TypeError: cannot convert numpy array to MATLAB array"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}