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¶
Data must often be stored to disk for a later Python session or for reading by other programs.
Data created by other programs may have to be read by Python.
Python has functions to read and write data in several standard forms: txt, csv, pickle, and hdf5.
Problems¶
Create a list and save it in a text file that each of the item in the list will take one line.
Save the same list in problem 1 to a CSV file.
Create a 2D
numpy
array, and save it to CSV file and read it back to a 2D array.Save the same array in problem 2 to a pickle file and load it back.
Create a dictionary and save it to a JSON file.
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 >