High-performance German economic classification (WZ) library
Project description
wz-code
High-performance Python package for working with German economic activity classifications (Wirtschaftszweigklassifikation).
Features
- Zero Configuration: Install and start using immediately
- High Performance: Sub-millisecond lookups, optimized memory usage
- Complete Data: Embedded WZ 2008 and WZ 2025 classifications
- Bidirectional Correspondences: Map between WZ 2025 and WZ 2008 versions
- CLI Tool: Use directly from command line
- Type Safe: Full type hints for IDE support
- Python 3.8+: Modern Python with backward compatibility
Installation
pip install wz-code
Quick Start
from wz_code import WZ
# Initialize with WZ 2025
wz = WZ(version="2025")
# Get a specific code
agriculture = wz.get("A")
print(agriculture.title)
# Output: Land- und Forstwirtschaft, Fischerei
# Navigate hierarchy
for child in agriculture.children:
print(f"{child.code}: {child.title}")
# Works with WZ 2008 too (full hierarchical structure)
wz2008 = WZ(version="2008")
code = wz2008.get("01.11.0")
print(f"Code: {code.code}, Level: {code.level}")
print(f"Ancestors: {[a.code for a in code.ancestors]}")
# Find correspondences between WZ versions
wz = WZ(version="2025")
code = wz.get("01.13.1")
correspondences = code.correspondences
for corr in correspondences:
match_type = "partial" if corr.is_partial else "full"
print(f"{corr.code}: {corr.title} ({match_type} match)")
# Output:
# 01.13.1: Anbau von Gemüse und Melonen (full match)
# 01.19.9: Anbau von sonstigen einjährigen Pflanzen a. n. g. (partial match)
# 01.28.0: Anbau von Gewürzpflanzen... (partial match)
Command-Line Interface
The package includes a CLI tool for quick lookups and exploration:
Get code information
# Get info about a code
wz-code get A
# Use WZ 2008
wz-code get 01.11 -v 2008
# Output as JSON
wz-code get A --json
Search for codes
# Search in titles
wz-code search "Landwirtschaft"
# Limit results
wz-code search "Herstellung" --limit 10
# Case-sensitive search
wz-code search "LAND" --case-sensitive
List codes
# List top-level codes
wz-code list --top-level
# List codes at specific level
wz-code list --level 2
# List with hierarchy indentation
wz-code list --indent
Display tree view
# Show full tree for a code
wz-code tree A
# Limit depth
wz-code tree A --depth 2
# JSON tree output
wz-code tree 01 --json
Map between WZ versions
# Show correspondences for a code
wz-code map 01.13.1
# Works with WZ 2008 too
wz-code map 01.19.9 -v 2008
# JSON output
wz-code map 01.13.1 --json
Development
Install in development mode:
poetry install --with dev
Run tests:
poetry run pytest
Generate data modules from XML sources:
poetry run python -m wz_code._build.generator \
--wz2025 source/WZ_2025_DE_2025-08-19.xml \
--wz2008 source/WZ_2008_DE_2025-09-29.xml \
--correspondences source/WZ2025-2025-08-19-Correspondences.xml
License
MIT License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wz_code-0.2.0.tar.gz.
File metadata
- Download URL: wz_code-0.2.0.tar.gz
- Upload date:
- Size: 127.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.7 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dade8b25a84a834d8aa09ae47f3547fe8de159b36e062839737d433a9e0282d4
|
|
| MD5 |
3651eafc9d64f4c756f28d904ff82eba
|
|
| BLAKE2b-256 |
6d749e882899c6fe0b7a54f732e988263db7f6f83b060b42299810b777f96fd5
|
File details
Details for the file wz_code-0.2.0-py3-none-any.whl.
File metadata
- Download URL: wz_code-0.2.0-py3-none-any.whl
- Upload date:
- Size: 135.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.7 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de430efdfd560fe81a110b28d8188a95b9ba3383b1f86f0df91f1e54faf92c9b
|
|
| MD5 |
62c930d36abdedcb0a63195198aa2733
|
|
| BLAKE2b-256 |
837ad203118b2cd8367d0afa101a19a0d3758160811372dc5b42103908a858e9
|