My program runs but it is soooooooooo slow. I have lots of data files I am reading and this for loop is where the program takes FOREVER.......N ote I declare data_ncdc=[] and ncdc_station=[]. Any suggestions would be appreciated.... . THANKS!!!!!
Code:
for il in range(len(data_ncdc)):
coord_ind = common_index(ave_lon_ncdc,ave_lat_ncdc, data_ncdc[il][0], data_ncdc[il][1])
if coord_ind == None:
ave_lon_ncdc.append(float(data_ncdc[il][0]))
ave_lat_ncdc.append(float(data_ncdc[il][1]))
ncdc_station.append(float(data_ncdc[il][3]))
else:
ncdc_station[coord_ind[0]].extend(float(data_ncdc[il][3]))
def common_index(list1, list2, val1, val2):
assert len(list1) == len(list2), "List not of equal length"
for i in range(len(list1)):
if list1[i] == val1 and list2[i] == val2:
return [i]
Comment