READING AND WRITING FILES
- open and close
- .read()
- .readline()
- .readlines()
WRITING TO A FILE
- start with f = open()
- .write()
LOOPING OVER THE LINES TO PROCESS THE CONTENT
FILE EXAMPLE:
This file contains the average daily high and low
temperatures per month for Auckland Airport
Jan 23 16
Feb 24 17
Mar 22 15
Apr 20 13
May 17 11
Jun 15 9
Jul 14 8
Aug 15 8
Sep 16 10
Oct 18 11
Nov 19 13
Dec 22 15
PART 1: EXTRACTING THE DATA
- Step 1: Open the file
- Step 2: read the header
- Step 3: store the next lines using f.readlines()
- Step 4: define three lists for months maxs and mins
- Step 5: create a loop
- Step 6: Split each data with the space using .split()
- Step 7: append each data into the correct list
PART 2: CREATING THE GRAPH FOR THE DATA
- Step 1: import pylab
- Step 2: plot the graphs