Skip to main content

Load data from v7.3 *.mat files. Only reading is supported, no writing.

Usage

Provides a class Hdf5Matfile and a convience function load_hdf5mat.

To load all the variables from the file, use Hdf5Matfile.load_file:

with Hdf5Matfile(filename) as file:
    data = file.load_file()

To fully load a specific variable from disk, use Hdf5Matfile.load_variable:

with Hdf5Matfile(filename) as file:
    results = file.load_variable('results')

For partial loading, a mapping/dict-like interface is also supported:

with Hdf5Matfile(filename) as file:
    results = file['results']
    time = results[0, :]
    disp = results[1, :]
    ...

If you’re not using a context manager, make sure to close the file after you’re done:

file = Hdf5Matfile(filename)
data = file.load_file()
...
file.close()

By default, arrays are not squeezed; since MATLAB represents even scalars as 2-D arrays, this means that something you expect to be a scalar will in fact be a 1-by-1 np.ndarray. You can change this by passing squeeze=True to the constructor:

with Hdf5Matfile(filename, squeeze=True) as file:
    data = file.load_file()

Supported data types

Data type support is pretty limited; this isn’t a terribly fancy class. Supported MATLAB data types, and the Python objects or NumPy dtypes they map to:

MATLAB type

Python object

NumPy dtype

cell

np.ndarray

object

char

str

n/a

double

np.ndarray

np.double

int8

np.ndarray

np.int8

int16

np.ndarray

np.int16

int32

np.ndarray

np.int32

int64

np.ndarray

np.int64

logical

np.ndarray

np.bool8

single

np.ndarray

np.single

struct (scalar)

dict

n/a

struct (array)

np.ndarray

object (dict)

uint8

np.ndarray

np.uint8

uint16

np.ndarray

np.uint16

uint32

np.ndarray

np.uint32

uint64

np.ndarray

np.uint64

Metadata

Release files for hdf5matfile 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hdf5matfile 0.4.1
File Size Uploaded
hdf5matfile-0.4.1.tar.gz 12.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hdf5matfile 0.4.1
File Interpreter ABI Platform
hdf5matfile-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 28.0 kB

Release files / hdf5matfile-0.4.1.tar.gz

Download URL hdf5matfile-0.4.1.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2e9f87cd7a6b7a113191fc79e6650c99916f318abea3c08b910385a6c95b1216
BLAKE2b-256 checksum
How to use checksums
2e8049d84e12c8966adb0dda2fe3a892fb8b3b7a0ee5e37383f2bae22a5f102d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

Release files / hdf5matfile-0.4.1-py3-none-any.whl

Download URL hdf5matfile-0.4.1-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5c708f8ed1fc6183225d533118439eb1715781661e3abb5e8b96d8db11e91e7
BLAKE2b-256 checksum
How to use checksums
0bd025b7739d584436e3298f3505bddd85d92762167adf0f5771bfc39d3436fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.2.2

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page