# 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
```bash
pip install wz-code
```
## Quick Start
```python
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
```bash
# 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
```bash
# 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
```bash
# 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
```bash
# 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
```bash
# 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:
```bash
poetry install --with dev
```
Run tests:
```bash
poetry run pytest
```
Generate data modules from XML sources:
```bash
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/bandbyte/wz-code",
"name": "wz-code",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "wz, classification, german, wirtschaftszweig, economic, statistics",
"author": "Paul Porstendorfer",
"author_email": "paul.porstendorfer@bandbyte.com",
"download_url": "https://files.pythonhosted.org/packages/fa/15/f7b9d5ed70e2b8a82383afd5fd92510460ed0dfe1556c59154c7a4fb3c5a/wz_code-0.1.0.tar.gz",
"platform": null,
"description": "# wz-code\n\nHigh-performance Python package for working with German economic activity classifications (Wirtschaftszweigklassifikation).\n\n## Features\n\n- **Zero Configuration**: Install and start using immediately\n- **High Performance**: Sub-millisecond lookups, optimized memory usage\n- **Complete Data**: Embedded WZ 2008 and WZ 2025 classifications\n- **Bidirectional Correspondences**: Map between WZ 2025 and WZ 2008 versions\n- **CLI Tool**: Use directly from command line\n- **Type Safe**: Full type hints for IDE support\n- **Python 3.8+**: Modern Python with backward compatibility\n\n## Installation\n\n```bash\npip install wz-code\n```\n\n## Quick Start\n\n```python\nfrom wz_code import WZ\n\n# Initialize with WZ 2025\nwz = WZ(version=\"2025\")\n\n# Get a specific code\nagriculture = wz.get(\"A\")\nprint(agriculture.title)\n# Output: Land- und Forstwirtschaft, Fischerei\n\n# Navigate hierarchy\nfor child in agriculture.children:\n print(f\"{child.code}: {child.title}\")\n\n# Works with WZ 2008 too (full hierarchical structure)\nwz2008 = WZ(version=\"2008\")\ncode = wz2008.get(\"01.11.0\")\nprint(f\"Code: {code.code}, Level: {code.level}\")\nprint(f\"Ancestors: {[a.code for a in code.ancestors]}\")\n\n# Find correspondences between WZ versions\nwz = WZ(version=\"2025\")\ncode = wz.get(\"01.13.1\")\ncorrespondences = code.correspondences\n\nfor corr in correspondences:\n match_type = \"partial\" if corr.is_partial else \"full\"\n print(f\"{corr.code}: {corr.title} ({match_type} match)\")\n# Output:\n# 01.13.1: Anbau von Gem\u00fcse und Melonen (full match)\n# 01.19.9: Anbau von sonstigen einj\u00e4hrigen Pflanzen a. n. g. (partial match)\n# 01.28.0: Anbau von Gew\u00fcrzpflanzen... (partial match)\n```\n\n## Command-Line Interface\n\nThe package includes a CLI tool for quick lookups and exploration:\n\n### Get code information\n\n```bash\n# Get info about a code\nwz-code get A\n\n# Use WZ 2008\nwz-code get 01.11 -v 2008\n\n# Output as JSON\nwz-code get A --json\n```\n\n### Search for codes\n\n```bash\n# Search in titles\nwz-code search \"Landwirtschaft\"\n\n# Limit results\nwz-code search \"Herstellung\" --limit 10\n\n# Case-sensitive search\nwz-code search \"LAND\" --case-sensitive\n```\n\n### List codes\n\n```bash\n# List top-level codes\nwz-code list --top-level\n\n# List codes at specific level\nwz-code list --level 2\n\n# List with hierarchy indentation\nwz-code list --indent\n```\n\n### Display tree view\n\n```bash\n# Show full tree for a code\nwz-code tree A\n\n# Limit depth\nwz-code tree A --depth 2\n\n# JSON tree output\nwz-code tree 01 --json\n```\n\n### Map between WZ versions\n\n```bash\n# Show correspondences for a code\nwz-code map 01.13.1\n\n# Works with WZ 2008 too\nwz-code map 01.19.9 -v 2008\n\n# JSON output\nwz-code map 01.13.1 --json\n```\n\n## Development\n\nInstall in development mode:\n\n```bash\npoetry install --with dev\n```\n\nRun tests:\n\n```bash\npoetry run pytest\n```\n\nGenerate data modules from XML sources:\n\n```bash\npoetry run python -m wz_code._build.generator \\\n --wz2025 source/WZ_2025_DE_2025-08-19.xml \\\n --wz2008 source/WZ_2008_DE_2025-09-29.xml \\\n --correspondences source/WZ2025-2025-08-19-Correspondences.xml\n```\n\n## License\n\nMIT License - see LICENSE file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "High-performance German economic classification (WZ) library",
"version": "0.1.0",
"project_urls": {
"Documentation": "https://github.com/bandbyte/wz-code#readme",
"Homepage": "https://github.com/bandbyte/wz-code",
"Issues": "https://github.com/bandbyte/wz-code/issues",
"Repository": "https://github.com/bandbyte/wz-code"
},
"split_keywords": [
"wz",
" classification",
" german",
" wirtschaftszweig",
" economic",
" statistics"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "947a371ab58ae5fe3aec73e9a295233cbe3ae1c0f95202653c6a990b01506075",
"md5": "9a34da12c79bfbab997917dcebc6abc6",
"sha256": "d2b663ec239c8d8e409874f8379dc40ca8d47326f38b85aa1c2ccee6e866c1fe"
},
"downloads": -1,
"filename": "wz_code-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9a34da12c79bfbab997917dcebc6abc6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 135075,
"upload_time": "2025-10-19T17:57:53",
"upload_time_iso_8601": "2025-10-19T17:57:53.280875Z",
"url": "https://files.pythonhosted.org/packages/94/7a/371ab58ae5fe3aec73e9a295233cbe3ae1c0f95202653c6a990b01506075/wz_code-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fa15f7b9d5ed70e2b8a82383afd5fd92510460ed0dfe1556c59154c7a4fb3c5a",
"md5": "6b499ec3b3c7205b75d79b164fbda653",
"sha256": "a2eb53525aef75bb8e08d83d7751564114bf5ce7c6d01e13bf94ddc4c2c43b5e"
},
"downloads": -1,
"filename": "wz_code-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "6b499ec3b3c7205b75d79b164fbda653",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 127613,
"upload_time": "2025-10-19T17:57:54",
"upload_time_iso_8601": "2025-10-19T17:57:54.955880Z",
"url": "https://files.pythonhosted.org/packages/fa/15/f7b9d5ed70e2b8a82383afd5fd92510460ed0dfe1556c59154c7a4fb3c5a/wz_code-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-19 17:57:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bandbyte",
"github_project": "wz-code",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "wz-code"
}