Build Reusable Cleaning Functions
Unit ID: M10-U03 Estimated active time: 50-70 minutes
Use small functions with explicit parameters and return values. Avoid functions that secretly read global variables or write files while validating one value.
def clean_identifier(value: str) -> str:
"""Return a trimmed uppercase identifier or raise ValueError."""
cleaned = value.strip().upper()
if not cleaned:
raise ValueError("identifier is required")
return cleaned
Keep calculation separate from display. Return structured results such as clean rows, rejected rows, and a summary. Write files in a later orchestration step.
Test each function with normal, boundary, missing, and invalid inputs before trusting the complete pipeline.
