Skip to content

Xilu012 Parsed Csv

src.xil_pipeline.XILU012_parsed_csv

Export parsed_.json entries to CSV — one row per script entry.

Produces the same column layout as XILP001 --debug minus the two markdown-source columns (md_line_num, md_raw) that are only available during a live parse run. Use this to inspect, diff, or spreadsheet-import an already-parsed episode without re-running the parser.

Output columns:: file, tag, show, season, episode, seq, type, section, scene, speaker, direction, direction_type, text

Text is truncated at 200 characters to match the XILP001 debug output. stdout is clean CSV (no banner) when no --output file is specified, so the output is safe to pipe directly to csvkit, jq (via --json), etc.

Usage:

xil parsed-csv                                       # all parsed JSONs in workspace
xil parsed-csv parsed/the413/parsed_S04E02.json      # single episode
xil parsed-csv parsed/the413/                        # all in a show directory
xil parsed-csv --output debug.csv                    # write to file (with banner)
xil parsed-csv --json | jq '[.[] | select(.type=="direction")]'

logger module-attribute

logger = get_logger(__name__)

ALL_COLS module-attribute

ALL_COLS = ['file', 'tag', 'show', 'season', 'episode'] + _ENTRY_COLS

get_parser

get_parser() -> argparse.ArgumentParser
Source code in src/xil_pipeline/XILU012_parsed_csv.py
def get_parser() -> argparse.ArgumentParser:
    parser = argparse.ArgumentParser(
        prog="xil-parsed-csv",
        description="Export parsed_<tag>.json entries to CSV — one row per entry",
    )
    parser.add_argument(
        "path",
        nargs="?",
        default="__parsed_default__",
        help="parsed JSON file, or directory containing parsed_*.json files (default: workspace parsed/)",
    )
    parser.add_argument(
        "--output", "-o",
        default=None,
        metavar="FILE",
        help="Write CSV to FILE (default: stdout)",
    )
    parser.add_argument(
        "--json",
        action="store_true",
        help="Output a JSON array to stdout — no banner, safe to pipe to jq",
    )
    return parser

main

main() -> None

CLI entry point for parsed JSON → CSV export.

Source code in src/xil_pipeline/XILU012_parsed_csv.py
def main() -> None:
    """CLI entry point for parsed JSON → CSV export."""
    args = get_parser().parse_args()
    if args.json or args.output is None:
        _run(args)
    else:
        configure_logging()
        with run_banner():
            _run(args)