Skip to content

Instantly share code, notes, and snippets.

Created March 31, 2013 18:56
Show Gist options
  • Save anonymous/5281610 to your computer and use it in GitHub Desktop.
Save anonymous/5281610 to your computer and use it in GitHub Desktop.
Update de puntos
def InsertData(line, value):
data = line.split(',')
try:
res = cl.sql("select cartodb_id from hydrocarbons where the_geom=ST_SetSRID(ST_Point("+data[0]+", "+data[1]+"),4326) and price_date ='"+today+"'")
if res['total_rows'] == 1:
try:
cl.sql("update hydrocarbons set "+key+"_price="+data[3]+" where cartodb_id="+str(res['rows'][0]['cartodb_id'])+"")
print "updating new value of" + value
except CartoDBException as e:
print ("some error ocurred", e)
else:
try:
cl.sql("insert into hydrocarbons (the_geom, a_display, "+key+"_price, price_date) values (ST_SetSRID(ST_Point("+data[0]+", "+data[1]+"),4326), '"+data[2]+"', "+data[3]+", '"+today+"')")
print "inserting new value of" + value
except CartoDBException as e:
print ("some error ocurred", e)
except CartoDBException as e:
print ("some error ocurred", e)
#LLAMADA A LA FUNCION
for line in rline:
InsertData(line, value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment