Loģisks budžeta modelis (Source, Provision, Parameter, Actor, Purpose, Indicator, Rule, ClassItem, Allocation), nevis likuma pielikumu izkārtojuma kopija. Abi likumi: teksts un visi 12 pielikumi. Atpakaļsaderība: 2026 — 58 457 no 58 457, 2025 — 55 677 no 55 677 pielikumos drukāto skaitļu atjaunoti tikai no XML. Avoti (likumi.lv, klasifikāciju MK noteikumi), rīki, datu līgums B15, dokumentācija. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016679RwmHsuTFfxt26wP6rk
24 lines
1.4 KiB
Python
24 lines
1.4 KiB
Python
"""Code-name pairs from the hidden SAP BW (BEx) sheets inside the budget law annex files.
|
|
The printed annex tables show line names only; the hidden ZQZBC_* sheets carry the code next to the name.
|
|
Input: source/<year>/P01.XLSX, P02.XLSX, P03.XLSX, P05.XLSX, P11.XLSX Output: source/kodi/codepairs.json (name -> [codes])
|
|
Usage: python tools/kodi_no_sap.py [year] (default 2026)
|
|
"""
|
|
import sys, os, re, json, collections
|
|
TOOLS = os.path.dirname(os.path.abspath(__file__))
|
|
ROOT = os.environ.get('BUDGET_ROOT', os.path.dirname(TOOLS))
|
|
sys.path.insert(0, TOOLS)
|
|
from rd import sheets
|
|
year = sys.argv[1] if len(sys.argv) > 1 else '2026'
|
|
pairs = collections.OrderedDict()
|
|
for f in ('P01.XLSX', 'P02.XLSX', 'P05.XLSX', 'P03.XLSX', 'P11.XLSX'):
|
|
for name, rows in sheets(os.path.join(ROOT, 'source', year, f)):
|
|
if not name.startswith('ZQZ'):
|
|
continue
|
|
for r in rows:
|
|
for i in range(len(r) - 1):
|
|
c, nm = str(r[i]), r[i + 1]
|
|
if re.fullmatch(r'[A-Z]{0,3}\d[\dA-Z]*|[A-Z]{1,5}\d?T?|\d{4,5}', c) and isinstance(nm, str) and len(nm) > 3 and not nm.startswith('Nosaukums'):
|
|
pairs.setdefault(nm.strip(), set()).add(c)
|
|
json.dump({k: sorted(v) for k, v in pairs.items()}, open(os.path.join(ROOT, 'source', 'kodi', 'codepairs.json'), 'w', encoding='utf-8'), ensure_ascii=False, indent=0)
|
|
print('pairs', len(pairs))
|