import sys, io, json, os sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace") sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import build_cases as b sheet = b.load_sheet() records = json.loads(b.JSONF.read_text(encoding="utf-8")) mapping = b.build_mapping(sheet, records) row_by_id = {jid: row for row, jid in mapping.items()} sheet_by_row = {r["_row"]: r for r in sheet} targets = json.loads(sys.argv[1]) # list of [id, col] for jid, col in targets: row = row_by_id.get(jid) print(f"\n===== case {jid} col={col} sheet_row={row} =====") if row is None: print(" NO SHEET ROW MAPPED") continue rec = sheet_by_row.get(row) cell = rec.get(col) if not isinstance(cell, str): print(" CELL EMPTY / NON-STRING") continue lines = cell.split("\n") for i, ln in enumerate(lines): print(f"[{i}] {ln}")