mat73


Namemat73 JSON
Version 0.65 PyPI version JSON
download
home_pagehttps://github.com/skjerns/mat7.3
SummaryLoad MATLAB .mat 7.3 into Python native data types (via h5/hd5/hdf5/h5py)
upload_time2024-07-24 09:12:33
maintainerNone
docs_urlNone
authorskjerns
requires_pythonNone
licenseGPL3
keywords
VCS
bugtrack_url
requirements h5py numpy
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![pypi Version](https://img.shields.io/pypi/v/mat73)

# mat 7.3

Load MATLAB 7.3 .mat files into Python.

Starting with MATLAB 7.3, `.mat` files have been changed to store as custom `hdf5` files.
This means they cannot be loaded by `scipy.io.loadmat` any longer and raise.

```Python
NotImplementedError: Please use HDF reader for matlab v7.3 files, e.g. h5py
```

## Quickstart

This library loads MATLAB 7.3 HDF5 files into a Python dictionary.

```Python
import mat73
data_dict = mat73.loadmat('data.mat')
```

As easy as that!

By enabling `use_attrdict=True` you can even access sub-entries of `structs` as attributes, just like in MATLAB:

```Python
data_dict = mat73.loadmat('data.mat', use_attrdict=True) 
struct = data_dict['structure'] # assuming a structure was saved in the .mat
struct[0].var1 == struct[0]['var1'] # it's the same!
```

You can also specifiy to only load a specific variable or variable tree, useful to reduce loading times

```Python
data_dict = mat73.loadmat('data.mat', only_include='structure') 
struct = data_dict['structure'] # now only structure is loaded and nothing else

data_dict = mat73.loadmat('data.mat', only_include=['var/subvar/subsubvar', 'tree1/']) 
tree1 = data_dict['tree1'] # the entire tree has been loaded, so tree1 is a dict with all subvars of tree1
subsubvar = data_dict['var']['subvar']['subsubvar'] # this subvar has been loaded
```

## Installation

To install, run:

```
pip install mat73
```

Alternatively for most recent version:

```
pip install git+https://github.com/skjerns/mat7.3
```

## Datatypes

The following MATLAB datatypes can be loaded

| MATLAB                   | Python            |
| ------------------------ | ----------------- |
| logical                  | np.bool_          |
| single                   | np.float32        |
| double                   | np.float64        |
| int8/16/32/64            | np.int8/16/32/64  |
| uint8/16/32/64           | np.uint8/16/32/64 |
| complex                  | np.complex128     |
| char                     | str               |
| struct                   | list of dicts     |
| cell                     | list of lists     |
| canonical empty          | []                |
| missing                  | None              |
| sparse                   | scipy.sparse.csc  |
| Other (ie Datetime, ...) | Not supported     |

## Short-comings

- This library will __only__ load mat 7.3 files. For older versions use `scipy.io.loadmat`
- Proprietary MATLAB types (e.g `datetime`, `duriation`, etc) are not supported. If someone tells me how to convert them, I'll implement that
- For now, you can't save anything back to the .mat. It's a bit more difficult than expected, so it's not on the roadmap for now
- See also [hdf5storage](https://github.com/frejanordsiek/hdf5storage), which can indeed be used for saving .mat, but has less features for loading
- See also [pymatreader](https://gitlab.com/obob/pymatreader/) which has a (maybe even better) implementation of loading MAT files, even for older ones

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/skjerns/mat7.3",
    "name": "mat73",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "skjerns",
    "author_email": "nomail@nomail.com",
    "download_url": "https://files.pythonhosted.org/packages/92/61/0e6375513085b13ad23ab150fc83d4d8faa91cba56eb2f30b646259f8214/mat73-0.65.tar.gz",
    "platform": null,
    "description": "![pypi Version](https://img.shields.io/pypi/v/mat73)\n\n# mat 7.3\n\nLoad MATLAB 7.3 .mat files into Python.\n\nStarting with MATLAB 7.3, `.mat` files have been changed to store as custom `hdf5` files.\nThis means they cannot be loaded by `scipy.io.loadmat` any longer and raise.\n\n```Python\nNotImplementedError: Please use HDF reader for matlab v7.3 files, e.g. h5py\n```\n\n## Quickstart\n\nThis library loads MATLAB 7.3 HDF5 files into a Python dictionary.\n\n```Python\nimport mat73\ndata_dict = mat73.loadmat('data.mat')\n```\n\nAs easy as that!\n\nBy enabling `use_attrdict=True` you can even access sub-entries of `structs` as attributes, just like in MATLAB:\n\n```Python\ndata_dict = mat73.loadmat('data.mat', use_attrdict=True) \nstruct = data_dict['structure'] # assuming a structure was saved in the .mat\nstruct[0].var1 == struct[0]['var1'] # it's the same!\n```\n\nYou can also specifiy to only load a specific variable or variable tree, useful to reduce loading times\n\n```Python\ndata_dict = mat73.loadmat('data.mat', only_include='structure') \nstruct = data_dict['structure'] # now only structure is loaded and nothing else\n\ndata_dict = mat73.loadmat('data.mat', only_include=['var/subvar/subsubvar', 'tree1/']) \ntree1 = data_dict['tree1'] # the entire tree has been loaded, so tree1 is a dict with all subvars of tree1\nsubsubvar = data_dict['var']['subvar']['subsubvar'] # this subvar has been loaded\n```\n\n## Installation\n\nTo install, run:\n\n```\npip install mat73\n```\n\nAlternatively for most recent version:\n\n```\npip install git+https://github.com/skjerns/mat7.3\n```\n\n## Datatypes\n\nThe following MATLAB datatypes can be loaded\n\n| MATLAB                   | Python            |\n| ------------------------ | ----------------- |\n| logical                  | np.bool_          |\n| single                   | np.float32        |\n| double                   | np.float64        |\n| int8/16/32/64            | np.int8/16/32/64  |\n| uint8/16/32/64           | np.uint8/16/32/64 |\n| complex                  | np.complex128     |\n| char                     | str               |\n| struct                   | list of dicts     |\n| cell                     | list of lists     |\n| canonical empty          | []                |\n| missing                  | None              |\n| sparse                   | scipy.sparse.csc  |\n| Other (ie Datetime, ...) | Not supported     |\n\n## Short-comings\n\n- This library will __only__ load mat 7.3 files. For older versions use `scipy.io.loadmat`\n- Proprietary MATLAB types (e.g `datetime`, `duriation`, etc) are not supported. If someone tells me how to convert them, I'll implement that\n- For now, you can't save anything back to the .mat. It's a bit more difficult than expected, so it's not on the roadmap for now\n- See also [hdf5storage](https://github.com/frejanordsiek/hdf5storage), which can indeed be used for saving .mat, but has less features for loading\n- See also [pymatreader](https://gitlab.com/obob/pymatreader/) which has a (maybe even better) implementation of loading MAT files, even for older ones\n",
    "bugtrack_url": null,
    "license": "GPL3",
    "summary": "Load MATLAB .mat 7.3 into Python native data types (via h5/hd5/hdf5/h5py)",
    "version": "0.65",
    "project_urls": {
        "Download": "https://github.com/skjerns/mat7.3/archive/v0.65.tar.gz",
        "Homepage": "https://github.com/skjerns/mat7.3"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c924e867b1b89b2a2102a5a3bb64ddcd49c5cb815244b2dadff7740c6a422e4f",
                "md5": "ee6d2d5e3796f7aed4f2382561a29515",
                "sha256": "aadfcd00f328eb8f75dd1d4a060a956dc0abefcf5af20f5bc69a5aae64d62cbf"
            },
            "downloads": -1,
            "filename": "mat73-0.65-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ee6d2d5e3796f7aed4f2382561a29515",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 19665,
            "upload_time": "2024-07-24T09:12:31",
            "upload_time_iso_8601": "2024-07-24T09:12:31.976559Z",
            "url": "https://files.pythonhosted.org/packages/c9/24/e867b1b89b2a2102a5a3bb64ddcd49c5cb815244b2dadff7740c6a422e4f/mat73-0.65-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "92610e6375513085b13ad23ab150fc83d4d8faa91cba56eb2f30b646259f8214",
                "md5": "d69d69418892b41d28036d0d07c904de",
                "sha256": "ad38a06af3d483632bd939ee572b3724ea8c03d37916765d7278f9de95541ade"
            },
            "downloads": -1,
            "filename": "mat73-0.65.tar.gz",
            "has_sig": false,
            "md5_digest": "d69d69418892b41d28036d0d07c904de",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 19355,
            "upload_time": "2024-07-24T09:12:33",
            "upload_time_iso_8601": "2024-07-24T09:12:33.007044Z",
            "url": "https://files.pythonhosted.org/packages/92/61/0e6375513085b13ad23ab150fc83d4d8faa91cba56eb2f30b646259f8214/mat73-0.65.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-24 09:12:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "skjerns",
    "github_project": "mat7.3",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "h5py",
            "specs": [
                [
                    ">=",
                    "3.0"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.19"
                ]
            ]
        }
    ],
    "lcname": "mat73"
}
        
Elapsed time: 0.66663s