Skip to main content

Load data from v7.3 *.mat files.

Project description

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 load a specific variable, use Hdf5Matfile.load_variable:

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

A mapping/dict-like interface is also supported:

with Hdf5Matfile(filename) as file:
    results = file['results']
    variables = file.keys()
    values = file.values()
    for var, value in file.items():
        ...

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hdf5matfile-0.3.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

hdf5matfile-0.3.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file hdf5matfile-0.3.1.tar.gz.

File metadata

  • Download URL: hdf5matfile-0.3.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using 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.5

File hashes

Hashes for hdf5matfile-0.3.1.tar.gz
Algorithm Hash digest
SHA256 8b1823583393048e04a3c5958c7ecf14fff0af8e0a580c62df3e28388232319a
MD5 77ecfb0727477fe94827e358527f4971
BLAKE2b-256 f0afbdaae9b59ad6af0c39759f0d91c954d547b8d6dda4c2b1f00290db53f753

See more details on using hashes here.

File details

Details for the file hdf5matfile-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: hdf5matfile-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using 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.5

File hashes

Hashes for hdf5matfile-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05f7e03ba4764bf5c909e8261a4d3425c2b12988694d583c109ff2aec56a3375
MD5 0a12512c80b2d8d39f342fad4e67ead2
BLAKE2b-256 84e96354f0fdb19f58eefef6718be38de124cc813856fd0f6fdda0a94b3d5926

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page