Using python beginner code
Lists and Files
I have gathered together some interesting data into a filecalled harvardLightning.txt
The file contains all recorded lightning strikes in the harvardarea
Parsing
Review alist =str.split() # alist will contain the elements of str – split usingwhitespace
Specifying a delimiter
Examples: delimiter = ‘,’ delimiter = ‘-‘, delimiter = ‘;’
Stripping specified characters
Example: astring.strip(‘n’)
Avoid blank lines: if len(line) == 0:
continue
Splitting on commas
DAY,CENTERLAT,CENTERLON,FCOUNT
2014-06-09,42.7,-73.8,99
The last number, highlighted in yellow, is the frequency oflightning strikes in the vicinity of UAlbany on the date listedfirst.
DAY,CENTERLAT,CENTERLON,FCOUNT
2014-04-10,42.7,-73.8,1
2014-04-21,42.7,-73.8,19
*
*
*
2014-09-03,42.7,-73.8,102
Your task is to extract the dates and the correspondingnumber of lightning strikes
2014-04-10 : 1 lightning strikes were recorded.
2014-04-21 : 19 lightning