Skip to main content

Fast Rust/PyO3 parser for ZS2 files with Parquet export

Project description

zs2fast

A fast Python extension for converting Zwick ZS2 test machine files to Parquet format, written in Rust/PyO3.

Features

  • Fast gzip decompression and binary parsing of .zs2 files
  • Extracts channel time-series data with automatic unit resolution
  • Extracts evaluated parameters and test results with units
  • Converts to Parquet format using Apache Arrow
  • Built with PyO3 for seamless Python integration
  • Supports Python 3.9–3.12 on Linux, macOS, and Windows

Installation

From PyPI

pip install zs2fast

From Source

Requires Rust and Python 3.9+.

# Install maturin
pip install maturin

# Clone and build
git clone https://github.com/weltidom/zs2fast.git
cd zs2fast
maturin develop --release

Usage

import zs2fast
import polars as pl

# Convert a .zs2 file to raw long-format Parquet
# Useful for exploring binary structure and raw values
zs2fast.zs2_to_parquet("input.zs2", "output.parquet", include_u32=False)
# columns: series, subtype, index, value

# Export channel time-series with semantic names and units
zs2fast.zs2_channels_to_parquet("input.zs2", "channels.parquet")
# columns: sample_idx, channel_idx, channel_name, unit, timepoint, value, data_type
channels = pl.read_parquet("channels.parquet")
print(channels.filter(pl.col('unit').is_not_null()).head())

# Export calculated test results (Bruchbild, elongation, max force, etc.)
# Units are resolved from EinheitName → QS_ValSetting blob → UnitTables
zs2fast.zs2_export_enriched_params_to_parquet("input.zs2", "evaluated_params.parquet")
# columns: sample_idx, param_id, short_name, param_name, unit, value, value_text
params = pl.read_parquet("evaluated_params.parquet")
print(params.filter(pl.col('value').is_not_null()).head())

# Extract per-sample test settings and parameters (not calculated results)
zs2fast.zs2_export_sample_results_to_parquet("input.zs2", "sample_params.parquet")
# columns: sample_id, result_id, result_name, unit, value_text, value
sample_params = pl.read_parquet("sample_params.parquet")
print(sample_params.head())

Which Parameter Export Should I Use?

Both APIs read the per-sample ParameterListe, but they optimize for different goals.

Function Primary goal Output columns Notes
zs2_export_enriched_params_to_parquet Build a normalized parameter table with strong metadata enrichment sample_idx, param_id, short_name, param_name, unit, value, value_text Best for analysis tables where stable names/units matter most
zs2_export_sample_results_to_parquet Preserve per-sample result rows as stored/evaluated in ParameterListe sample_id, result_id, result_name, unit, value_text, value Includes branch-aware parsing to avoid nested/outer path collisions

Practical Rule

  • Use zs2_export_enriched_params_to_parquet when you want a canonical analysis-ready parameter table.
  • Use zs2_export_sample_results_to_parquet when you want the closest representation of per-sample evaluated result entries.

Naming and Deprecation

Preferred names:

  • zs2_export_enriched_params_to_parquet
  • zs2_export_sample_results_to_parquet

Legacy names remain supported but now emit runtime DeprecationWarning:

  • zs2_evaluated_params_to_parquet
  • zs2_parameterliste_results_to_parquet

Use the new names in notebooks and scripts going forward.

Unit Resolution

The parser automatically resolves measurement units using a 3-tier strategy:

  1. Direct unit name (EinheitName field) — Direct unit symbol (mm, N, MPa, etc.)
  2. Unit table key (from QS_ValSetting binary blob) — References /UnitTables section (UT_Length → mm, UT_Force → N, etc.)
  3. Fallback inference — Attempts to infer units from table key name

Channels typically use tier 1–2, while evaluated parameters primarily use tiers 2–3. This ensures maximum unit coverage across different .zs2 file structures.

Development

Build

maturin build --release

Note: for this PyO3 extension module on macOS, prefer maturin build/maturin develop. Running plain cargo build --release can fail with unresolved Python symbols (_Py*, __Py_*) during linking.

Lint

cargo fmt
cargo clippy

Test

cargo test

License

See LICENSE file for details.

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

zs2fast-0.5.0.tar.gz (29.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

zs2fast-0.5.0-cp39-abi3-win_amd64.whl (3.0 MB view details)

Uploaded CPython 3.9+Windows x86-64

zs2fast-0.5.0-cp39-abi3-manylinux_2_34_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ x86-64

zs2fast-0.5.0-cp39-abi3-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file zs2fast-0.5.0.tar.gz.

File metadata

  • Download URL: zs2fast-0.5.0.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for zs2fast-0.5.0.tar.gz
Algorithm Hash digest
SHA256 49544d46aa656cdeb603b7b70cf05370024f51e334c9be01fbac2abeb3cb01c8
MD5 1a17ec92412077d1df58116aa4d8953f
BLAKE2b-256 2700961830c82f4e927e49da284fd29ddb7b4212bb6209c249f8da424774a0a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for zs2fast-0.5.0.tar.gz:

Publisher: publish.yml on weltidom/zs2fast

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zs2fast-0.5.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: zs2fast-0.5.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for zs2fast-0.5.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2bc713a5cdcf673a90fc649cecf6d665205c4fcd798262910c71798bd1860b44
MD5 5642828618f18703d433c917a3379f56
BLAKE2b-256 e9541ba5016c95e6244c6cb7c4fce2d88a5386791130d0ca25b60d84fb1bfcdc

See more details on using hashes here.

Provenance

The following attestation bundles were made for zs2fast-0.5.0-cp39-abi3-win_amd64.whl:

Publisher: publish.yml on weltidom/zs2fast

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zs2fast-0.5.0-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for zs2fast-0.5.0-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 39b50f9e92aeb8e64894f0c30ad72316828cb68cced9e6d89121b7ad3868ee9f
MD5 3887a685f1a7b826ca6c136ac1f46897
BLAKE2b-256 649c9ec176c324f60d5613646ca0a207d94dc77a406dc4994cce00695c7e3f99

See more details on using hashes here.

Provenance

The following attestation bundles were made for zs2fast-0.5.0-cp39-abi3-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on weltidom/zs2fast

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zs2fast-0.5.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for zs2fast-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b3ce501d2a751312eb9339d09150d0fe5e9db487cb431f9b40c700b48fcd07d1
MD5 67b58d42d4b1fbc38a1ad9bd98150f92
BLAKE2b-256 e2b5376a005cb44c24096ff45e6c60e4a1fde13455fd6d16c923dbd718f7bd8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for zs2fast-0.5.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on weltidom/zs2fast

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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