Files
LabDataStorageEvaluation/docs/specs_old/09_cleanse_normalize.md
administrator b173ac82a9 fix(docs): fix formatting issues in README.md
- adapt meta-/code-/obs- rules to the local Python benchmark pipeline
- replace db-sql-ddl, code-config-env-scope, test-e2e-pytest with pipeline equivalents
- add code-python-style, data-determinism, data-naming-units, bench-methodology, build-pipeline-tasks
- normalize specs and README typography to ASCII per code-data-formatting
- rewrite root CLAUDE.md trigger table; add .cursorrules and .gitignore
- specs: pipeline plan and task specs 00-11
- rules: 19 binding rule files adapted for this project
- docs: CLAUDE.md rule-trigger table
- config: .cursorrules commit convention, .gitignore excluding out/ and .venv/
- docs: rewrite README.md with pipeline diagrams, setup guide, result placeholders
- config: requirements.txt for the closed dependency list
- datagen: make_lab_config.py writes out/config/lab_config.yaml and .done marker
2026-07-11 13:39:13 -04:00

1.4 KiB

Task 09 — Cleanse & Normalize → Canonical Dataset

Goal

Streamed transformation of all raw CSV into the canonical dataset; anomalies quarantined, lineage recorded.

Input

  • Mappings (Task 07), schema + instrument ranges (Task 08), config/anomaly_rules.json, tokens (Task 03).

Actions

  1. Write scripts/cleanse.py — streaming, constant memory, parallel by file, resumable (checkpoint by inventory offset).
  2. Per file: apply column mapping → coerce dtypes → normalize units → standardize codes (atmosphere, instrument) → resolve hierarchy keys from tokens (natural keys: batch/coupon/sample/run/test/cycle numbers).
  3. Anomaly checks per row: out-of-instrument-range, non-coercible type, missing required, duplicate key, sequence gap (per ordered series), malformed row. Reasons coded per anomaly_rules.json.
  4. Clean rows → canonical/<measurement_type>/… partitioned files (JSONL or Parquet; partition friction points by test/cycle per Phase-1 volume estimates). Rejected rows → rejects/<type>.jsonl with {source_file, row_offset, reason_code, raw_payload}.
  5. Lineage per output row: {source_file_id, row_offset, mapping_version, schema_version} → compact companion files in lineage/.

Intermediate Result (done when)

  • Every in-scope file processed; row counts reconcile: source ≈ canonical + rejects per file.
  • Canonical partitions written; lineage present for every canonical row.