Input and Output

In this chapter, we will cover some options for handling data files. Depending on the data and the desired format, there are several options for reading and writing. We will show some of the most useful alternatives.

The following topics will be covered in this chapter:

  • File handling
  • NumPy methods
  • Pickling
  • Shelves
  • Reading and writing Matlab data files
  • Reading and writing images

14.1 File handling

File input and output(I/O) is essential in a number of scenarios, for example:

  • Working with measured or scanned data. Measurements are stored in files that need to be read in order to be analyzed.
  • Interacting with other programs. Save results to files so that they can be imported into other applications, and vice-versa.
  • Storing ...

Get Scientific Computing with Python - Second Edition 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.