Closed valentineap closed 6 years ago
I corrected the unit in the data file (size should be in cm^3 not ^2) and added a bit of things for data save/load methods in Numpy.
It is too much to try covering other possibilities so I just added a mention to Pandas, HDF5 or Pickle at the end.
.jpg and .xlsx are mentioned in the first para, but then the exercise only deals with plain text formats.
While I agree that there are far too many formats to include, it might be good to add examples of reading specific, common types of files, such as images and excel files.
I've added this.
Also, it's common practice to handle file opening using a context manager (i.e. with
statement) to automatically handle file closing. It might be worth introducing this here, as it's good practice. I.e.
with open(file, 'r') as fp:
lines = fp.readlines()
I've done this (542a21e). Feel free to edit/revert if it's garbage!
@charlesll At this point in the course we have not introduced modules or numpy, hence I would like to move your additions to later on. I have therefore removed them from this practical, and added a note that we will see more ways of reading files later. I intend to use your additions in a later practical.
Ready for @rmcgirr94
Tested, fixed a typo, closing issue.
For review.
https://github.com/valentineap/ComputationalGeoscienceCourse/tree/master/Practicals/Exercise%2008%20-%20Reading%20and%20writing%20files
This is rather short, but I think there'll be plenty of practice of this in other contexts, and there isn't much to it. Do you think another exercise or two is required?