Lesson 3: Tables and records in CSV and JSON files
17 min read·14 Oct 2026
Module 8 · Lesson 3 · About 50 minutes · Needs: Module 8 Lessons 1 and 2 (tryandexcept,with open(...),encoding="utf-8"), Module 7 (datetime,pathlib), Module 5 (dictionaries, comprehensions)
The situation
"The real records are the files," Amira says. "Read those, and give me answers as files I can open." Books and loans are in books.csv and loans.csv, saved from her spreadsheet; members are in members.json, because each has a list of favourite genres.
This lesson reads all three, follows Jonah's loan L04 (Frankenstein, still out) the whole way, writes files back, and checks every row instead of trusting it.