../_images/book_cover.jpg

This notebook contains an excerpt from the Python Programming and Numerical Methods - A Guide for Engineers and Scientists, the content is also available at Berkeley Python Numerical Methods.

The copyright of the book belongs to Elsevier. We also have this interactive book online for a better learning experience. The code is released under the MIT license. If you find this content useful, please consider supporting the work on Elsevier or Amazon!

< 11.5 HDF5 Files | Contents | CHAPTER 12. Visualization and Plotting >

Summary

  1. Data must often be stored to disk for a later Python session or for reading by other programs.

  2. Data created by other programs may have to be read by Python.

  3. Python has functions to read and write data in several standard forms: txt, csv, pickle, and hdf5.

Problems

  1. Create a list and save it in a text file that each of the item in the list will take one line.

  2. Save the same list in problem 1 to a CSV file.

  3. Create a 2D numpy array, and save it to CSV file and read it back to a 2D array.

  4. Save the same array in problem 2 to a pickle file and load it back.

  5. Create a dictionary and save it to a JSON file.

  6. Create a 1D numpy array, and save it to a JSON file with the key named ‘data’. Then load it back.

< 11.4 HDF5 Files | Contents | CHAPTER 12. Visualization and Plotting >