"""
km_diagnose5.py
Searches LO, PA, AN, FR for a handful of known KM microwave call signs
by scanning raw lines -- bypasses any column mapping issues entirely.
"""
import os

ULS_DIR = r"D:\FCC_ULS"

# A sample of known active KM microwave call signs from HD
SAMPLE_CS = {
    "WPVY782","WPVY783","WQPL362","WQPL364","WNTU758","WNTU759",
    "WNTK845","WNTK846","WQGL488","WQQA792","KAL27","KAL30",
    "WIA659","WIA660","WPVV607","WPVV608"
}

for fname in ["PA.dat","LO.dat","AN.dat","FR.dat"]:
    fpath = os.path.join(ULS_DIR, fname)
    found = []
    with open(fpath, "r", encoding="latin-1") as f:
        for line in f:
            fields = line.split("|")
            if len(fields) > 4 and fields[4].strip() in SAMPLE_CS:
                found.append(fields[:8])
    print(f"\n{fname}: {len(found)} rows for sample KM call signs")
    for row in found[:10]:
        print(f"  {row}")
