CoursePython from Scratch to Intermediate · Module 8: Errors, Files and Debugging · part 57 of 75
Part 57 · Module 8: Errors, Files and Debugging

Lab: Load the shelf's files and check Tom's notebook

20 min read·14 Oct 2026
Module 8 · Lab · About 60 minutes · Needs: lessons 1 to 4 of this module, and the Module 7 lab (the booknook folder in your Drive)

What you are building

DATA/ RESULTS books.csv members.json loans.csv tom_notebook.txt booknook/ storage.py load, parse, save books, members, loans 24, 6, 40 8 clean loans from the notebook 5 problems lines 4, 5, 6, 8, 11 notebook_loans.csv saved
storage.py (blue) reads the four data files (grey) and gives back the records, Tom's 8 clean loans and a saved file (green), and 5 problems (red).

Amira's request for this module is "Load the real files and fix Tom's notes." The four lessons built every piece: loaders for the CSV and JSON files (Lesson 3), try and except to keep going past a bad line (Lesson 1), files opened with with and encoding="utf-8" (Lesson 2), and a hunt that named all five faults in Tom's notebook (Lesson 4).

This lab joins them into one new module, booknook/storage.py, with the five names the course fixed for it: load_books, load_members, load_loans, save_loans and parse_notebook. parse_notebook reads Tom's twelve lines and gives back two lists: the clean loans, and a problem for every faulty line, with its line number. The clean loans are saved to a new file, so the September loans are no longer lost.

Open a new Colab notebook, call it module-08-lab.ipynb, and run each cell in order.

The rest of this part opens with an account

Signing up is free and takes one email. Nothing to pay, and nothing renews.