CSV and JSON

Scenario: A service exports rows for spreadsheets and configuration for APIs.

New words, in plain English

Use csv.DictReader/DictWriter instead of splitting commas yourself. Use json.load/dump for files and loads/dumps for strings. JSON objects become dicts; arrays become lists.

Analogy: A Python program is like a clear set of instructions for a careful helper: names label things, indentation groups steps, and errors explain where the helper became confused.

A small, real example

import csv, json
with open("services.csv", newline="") as handle:
    rows = list(csv.DictReader(handle))
with open("services.json", "w") as handle:
    json.dump(rows, handle, indent=2)
Tip: Open CSV with newline="" so the csv module controls line endings.
Goal: Practice this idea in the py-csv-pathlib challenge at /labs/python. Fix the broken program, run it yourself, then use check to prove the real end state.