#monitorcount+=1 jdata = json.loads(body) #print jdata for value in jdata.values(): for child in value: for k, v in child.items(): if k == 'city' and v.split(' (')[0] == row[0]: childcount += 1 cn = row[1] city = child.get('city').split(' (')[0] #print city #print child.get('g') lat_0 = float(child.get('g')[0]) lon_0 = float(child.get('g')[1]) offset.transform(lat_0, lon_0) lat = round(offset.lat, 6) lon = round(offset.lon, 6) #check if lat lon falls in China bounding box try: if (lat > 53.559712 or lat < 15.781945) or ( lon < 73.560763 or lon > 134.770467): continue except: pass #check if the location of new records are already in the csv file, #If not exists, add a new location to the location csv file. cur.execute("SELECT * FROM location;") conn.commit()
#monitorcount+=1 jdata=json.loads(body) #print jdata for value in jdata.values(): for child in value: for k,v in child.items(): if k=='city' and v.split(' (')[0]==row[0]: childcount+=1 cn=row[1] city=child.get('city').split(' (')[0] #print city #print child.get('g') lat_0=float(child.get('g')[0]) lon_0=float(child.get('g')[1]) offset.transform(lat_0,lon_0) lat=round(offset.lat,6) lon=round(offset.lon,6) #check if lat lon falls in China bounding box try: if (lat>53.559712 or lat<15.781945) or (lon<73.560763 or lon>134.770467): continue except: pass #check if the location of new records are already in the csv file, #If not exists, add a new location to the location csv file. cur.execute("SELECT * FROM location;") conn.commit() locationList=cur.fetchall()