Input/Output, Physical Format, and Logical Layout

In this chapter, we'll look at the following recipes:

  • Using pathlib to work with filenames
  • Reading and writing files with context managers
  • Replacing a file while preserving the previous version
  • Reading delimited files with the CSV module
  • Reading complex formats using regular expressions
  • Reading JSON documents
  • Reading XML documents
  • Reading HTML documents
  • Upgrading CSV from DictReader to namedtuple reader
  • Upgrading CSV from DictReader to namespace reader
  • Using multiple contexts for reading and writing files

Get Modern Python Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.