promptdojo_

CSV and JSONL — the two formats AI moves data in — step 9 of 9

Checkpoint

One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.

Last drill. Convert a CSV into JSONL.

Write a function csv_to_jsonl(csv_path, jsonl_path) that:

  1. Opens csv_path with csv.DictReader (remember newline="").
  2. For each row, converts the score column from string to int.
  3. Writes one JSON object per line to jsonl_path.
  4. Returns the number of rows written.

The starter writes a tiny CSV, calls your function, then reads the JSONL back and prints each parsed record's name and score.

Expected output:

3
alex 82
sam 91
jordan 77

full-screen editor opens — close anytime to keep reading.