Python course

Python Level 8: Files & Data

Files & Data is level 8 of 17 of the LoWisa Python course. It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

Updated 2026-11-16

Files and Paths

  • open and with. The with statement opens a file and guarantees it closes, even when the block raises.
  • Reading and writing. read() takes the whole file; iterating the file object yields lines one at a time without loading everything.
  • pathlib. The pathlib module treats paths as objects: joining with / and asking exists() beats gluing strings together.

JSON, CSV and Serialisation

  • JSON. The json module turns dicts and lists into text and back: the wire format of nearly every API.
  • CSV. The csv module reads spreadsheet-shaped data row by row, handling quoting rules you should never hand-roll.
  • Pickle caution. pickle serialises arbitrary Python objects, but loading a pickle runs code: never unpickle untrusted bytes.

Resource Management

  • Context managers. Anything usable in a with statement is a context manager: it promises setup and guaranteed cleanup.
  • Encoding. Text files carry an encoding; declaring utf-8 explicitly is what keeps accents from becoming mojibake.
  • Atomic writes. Write to a temporary file and rename it into place: a crash mid-write then never leaves a half file.

Before and after this level

In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.

Frequently asked questions

What does Python Level 8: Files & Data cover?

Files and Paths, JSON, CSV and Serialisation, Resource Management: 3 lessons and 9 ideas.

What should I know before this level?

The level before it, Level 7: Errors & Debugging, which covers Exceptions, Debugging and Tracebacks, Designing Reliable Failure Handling.

Learn Python on your phone

The first level is free. LoWisa is on Google Play and the App Store.