Question: Assignment # 12: Lists and Files I have gathered together some interesting data into a file called UAlbanyLightning.txt The file contains all recorded lightning strikes

Assignment # 12: Lists and Files

I have gathered together some interesting data into a file called UAlbanyLightning.txt

The file contains all recorded lightning strikes in the UAlbany area

Parsing

Review alist = str.split() # alist will contain the elements of str - split using whitespace

Specifying a delimiter

Examples: delimiter = ',' delimiter = '-', delimiter = ';'

Stripping specified characters

Example: astring.strip(' ')

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 of lightning strikes in the vicinity of UAlbany on the date listed first.

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 corresponding number of lightning strikes

2014-04-10 : 1 lightning strikes were recorded.

2014-04-21 : 19 lightning strikes were recorded.

*

*

*

2014-09-03 : 102 lightning strikes were recorded.

See if you can output the data with a more familiar date format:

(Hint: split the date and rearrange the elements)

04 10 2014 : 1 lightning strikes were recorded.

04 21 2014 : 19 lightning strikes were recorded.

*

*

*

09 03 2014 : 102 lightning strikes were recorded.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!