Skip to main content

HDFPath

A python package to enable quick searches of Hierarchical Data Format (HDF)-Files based on JSONPath. These files include the HDF5-Format provided by h5py as well as more recent libraries like zarr. Like jsonpath-ng any data structure consisting of dict-like objects conforming to the collections.abc.Mapping-interface and lists is also supported.

This package is derived from the jsonpath-ng library. For the query syntax and capabilities please refer to the original documentation at https://github.com/h2non/jsonpath-ng

Installation

Using pip

pip install hdfpath

From source

git clone https://github.com/mortacious/hdfpath.git
cd hdfpath
python setup.py install

Usage

As HDF-Files are organized as groups containing datasets with both containing optional metadata attributes, this package adds support to use these attributes directly inside queries. With the optional metadata_attribute parameter to the parse function, the attribute to retrieve the metadata can be chosen.

from hdfpath import parse
import h5py as h5

with h5.File("<HDF5-File>") as f:
    # query for all groups/datasets of type "scan" with the num_points attribute being larger than 40_000_000
    expr = parse('$..*[?(@._type == "scan" & @._num_points > 40000000)]', metadata_attribute='attrs')
    val = [match.value for match in expr.find(f)]
    print(val)

The metadata attributes are accessible inside the query using the _ prefix. Additionally, the use of regular expressions to match the fields is available through the `regex()` function. For example `regex(\\\d+)` will only match groups/datasets that can be parsed into an integer number.

TODOs

  • code examples

Copyright and License

Copyright 2021 - Felix Igelbrink

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Metadata

Release files for hdfpath 0.1.0

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

Source distribution (sdist)

Source distribution for hdfpath 0.1.0
File Size Uploaded
hdfpath-0.1.0.tar.gz 30.1 kB Details

Built distribution (wheel)

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

Total release size: 56.8 kB

Release files / hdfpath-0.1.0.tar.gz

Download URL hdfpath-0.1.0.tar.gz
Size 30.1 kB
Tags Source
SHA-256 checksum
How to use checksums
674e4d514afa31de89c4918eb63434b38164725751ed32b24147cd61f54e29f4
BLAKE2b-256 checksum
How to use checksums
bc0327582b1f92bcaba829c60775fa292b8060731f73c1ed381a4db7612f749c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release files / hdfpath-0.1.0-py3-none-any.whl

Download URL hdfpath-0.1.0-py3-none-any.whl
Size 26.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32660824308f3af79ee6eeb1f7562fee37e6dfd0b1ccc333ec8df2bdf46f82c3
BLAKE2b-256 checksum
How to use checksums
8d5cb3a99fa81f99f32ac124f68cf6c2afe0b5b3e78680be849bfc5c22d026d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

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