"""
GLAMWalk -- Volume 4: Libraries & Archives
09_british_library_tsv_loader.py

Loading a British Library Mechanical Curator manifest file (TSV, not CSV) and applying the real per-row date check this source genuinely needs.

Source: Volume Four, Sections 2.1 and 2.3
Targets Python 3.11.4 -- see Volume One, Chapter 1.5/1.6.
"""

import csv

def load_bl_tsv(path):
    """
    British Library Mechanical Curator files are TSV, not CSV —
    tab-separated, not comma-separated. A surprisingly common
    real-world variant worth checking for on any new source.
    """
    records = []
    with open(path, newline="", encoding="utf-8") as f:
        reader = csv.DictReader(f, delimiter="\t")
        for row in reader:
            records.append(row)
    return records


def bl_row_qualifies(row):
    year = row.get("year")
    if not year or not year.isdigit():
        return False
    return int(year) < 1930
