This is an archived version of the course and is no longer updated. Please find the latest version of the course on the main webpage.

Libraries for different types of files

Besides simple text files, Python provides different libraries for handling specific types of files

  • csv – reading from and writing to Comma Separated Values (CSV) files
  • json – encoding and decoding JavaScript Object Notation (JSON) data
  • xml.etree.ElementTree - creating and reading XML files
  • wave and aifc – reading from and writing to audio files
  • tarfile – reading and writing tar archive files
  • zipfile – working with ZIP archives
  • configparser – creating and parsing configuration files

There are also third party tools for reading and manipulating different files

  • PyPDF2 – PDF toolkit
  • Pillow – image reading and manipulation

We will look at two of these in this module: csv and json.