Skip to content

File handling

This guide covers reading and writing files in Python — the open built-in, pathlib, context managers, CSV and JSON, and the encoding gotchas that bite learners.

Coming soon

This guide is awaiting migration into Agilearn. The archived version remains available at accuser.dev/file-handling-with-python.

What will be here

Learn — reading files, writing files, working with paths via pathlib, CSV and JSON.

Recipes — processing large files, binary files, temporary files, avoiding common mistakes.

Referenceopen options and file modes, pathlib quick reference.

Concepts — why context managers matter; understanding file encodings.