mat73


Namemat73 JSON
Version 0.63 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-03-23 16:44:12
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
```

## 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/44/d4/ed1749e8c7dcde6000755bfd18a436dfc9eec9a5b816f2de1b9637432cfa/mat73-0.63.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\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.63",
    "project_urls": {
        "Download": "https://github.com/skjerns/mat7.3/archive/v0.63.tar.gz",
        "Homepage": "https://github.com/skjerns/mat7.3"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0e7c16a3a27f3a38b0722558dfafff59c9a24f020adaa116445ca4d358707cd",
                "md5": "06e8eb74135666179ddcc6c8add457c2",
                "sha256": "9708cd704535ebdbb2603816c7aaa0a85fec4f26da4c9a6b36c8fa803f668fa6"
            },
            "downloads": -1,
            "filename": "mat73-0.63-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "06e8eb74135666179ddcc6c8add457c2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 19477,
            "upload_time": "2024-03-23T16:44:11",
            "upload_time_iso_8601": "2024-03-23T16:44:11.122045Z",
            "url": "https://files.pythonhosted.org/packages/f0/e7/c16a3a27f3a38b0722558dfafff59c9a24f020adaa116445ca4d358707cd/mat73-0.63-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "44d4ed1749e8c7dcde6000755bfd18a436dfc9eec9a5b816f2de1b9637432cfa",
                "md5": "08218391c1615caf78407bfb3eec4d91",
                "sha256": "c7e901e302d8172e6f1871819fb3f5f3d4a723c08c5aebde5d8d7b45e687d20b"
            },
            "downloads": -1,
            "filename": "mat73-0.63.tar.gz",
            "has_sig": false,
            "md5_digest": "08218391c1615caf78407bfb3eec4d91",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 18883,
            "upload_time": "2024-03-23T16:44:12",
            "upload_time_iso_8601": "2024-03-23T16:44:12.782573Z",
            "url": "https://files.pythonhosted.org/packages/44/d4/ed1749e8c7dcde6000755bfd18a436dfc9eec9a5b816f2de1b9637432cfa/mat73-0.63.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-23 16:44:12",
    "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.21748s