with open("top10.csv") as f: cols = [] for line in f: items = line.split(',') cols = cols + items[3::3] # print cols floats = [float(i) for i in cols] maxVal = max(floats) minVal = min(floats) print maxVal print minVal data = list() f3 = open('out.json', 'w') outstr = '[' with open('top10.csv') as f2: for line in f2: items = line.split(',') # parse the columns day, lat1, lon1, t1 = items[:4] # parse the columns lat2, lon2, t2 = items[58:] # parse the columns #print items normalizedData = (float(t1)-float(minVal))/(float(maxVal)-float(minVal)) normalizedDatax = (float(t2)-float(minVal))/(float(maxVal)-float(minVal)) #print normalizedData # 720, 1440 lat = -90.0 + 0.25 * float(lat1) + 0.025 lon = -180.0 + 0.25 * float(lon1) + 0.025 latx = -90.0 + 0.25 * float(lat2) + 0.025 lonx = -180.0 + 0.25 * float(lon2) + 0.025 # f3.write(''.join(['["',day, '",',' [', tmpstr = ''.join(['["',day, '",',' [', str(lat),',',str(lon),',',str(normalizedData),',', str(latx),',',str(lonx),',',str(normalizedDatax), ']],']) # print tmpstr outstr = outstr+tmpstr f3.write(outstr[:-1]+']') f3.close()