# L-6 MCS 275 Mon 25 Jan 2010 : earthquakes.py # Selects from the file quakes.cvs the latitude and longitude # of those quakes of magnitude above a certain threshold. import turtle file = "quakes.cvs" from makedata import ShowData def SelectData(m): """ Opens the file and returns list of ongitudes and latitudes of quakes of magnitude larger than or equal to m. Because latitude runs vertically, latitude is y and longitude is x. """ R = [] f = open(file,'r') s = f.readline() while True: s = f.readline() if s == '': break L = s.split(',') try: M = float(L[4]) except: M = 0 if M >= m: p = (float(L[3]),float(L[2])) R.append(p) return R def Round(L): """ Rounds all coordinates to the nearest integer. """ R = [] for each in L: p = (int(round(each[0])),int(round(each[1]))) R.append(p) return R def main(): """ Visualization of locations of largest earth quakes. """ m = input("give threshold magnitude : ") K = SelectData(m) # print K L = [Round(K)] # print L turtle.hideturtle() ShowData(L) ans = raw_input("hit enter to exit ...") main()