#!/usr/bin/env python3 """Reproduce the published CSV arithmetic. No network or extra packages needed. Place this script beside package-row-counts.csv and publication-entry-ledger.csv. These checks verify ledger/tabulation consistency, not independent clinical tests. """ import csv, collections, json from pathlib import Path p=Path(__file__).resolve().parent with (p/'package-row-counts.csv').open() as f: packages=list(csv.DictReader(f)) with (p/'publication-entry-ledger.csv').open() as f: ledger=list(csv.DictReader(f)) by_url=collections.Counter(r['url'] for r in ledger) assert len(packages)==len(by_url)==78 for row in packages: assert by_url[row['url']]==int(row['publication_entry_rows']) assert int(row['all_table_rows'])==sum(int(row[k]) for k in ['column_header_rows','section_header_rows','publication_entry_rows']) totals={k:sum(int(r[k]) for r in packages) for k in ['all_table_rows','column_header_rows','section_header_rows','publication_entry_rows']} assert totals=={'all_table_rows':4091,'column_header_rows':298,'section_header_rows':312,'publication_entry_rows':3481} print(json.dumps({'packages':len(packages),'totals':totals,'ledger_entries':len(ledger),'scope':'Publication entries, not distinct medical tests'},indent=2))