I have to analyze earthquake data, and before I can begin analyzing the data, I have to change the format of the way the data is listed. I have to change the format from:
14km WSW of Willow, Alaska$2.4
4km NNW of The Geysers, California$0.9
13km ESE of Coalinga, California$2.1
...
to:
["2.4, 14km WSW of Willow, Alaska", "0.9, 4km NNW of The Geysers, California",
"2.1, 13km ESE of Coalinga, California", ...]
The code that I have for the original format (omitting the url) is:
def fileToList(url):
alist = []
source = urllib2.urlopen(url)
for line in source:
items = line.strip()
alist.append(items)
return alist
I'm trying to create variables magnitude and earthquakeloc to rearrange the format of alist, but I just don't know where to start. I am very new to coding. Any suggestions would be wonderful, thank you.