Skip to content

Instantly share code, notes, and snippets.

@dalanmiller
Created June 23, 2015 21:16
Show Gist options
  • Save dalanmiller/3a828dfeaa7c2b2736d0 to your computer and use it in GitHub Desktop.
Save dalanmiller/3a828dfeaa7c2b2736d0 to your computer and use it in GitHub Desktop.
import rethinkdb as r
url = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_month.geojson"
def refresh_quakes():
conn = r.connect()
r.db("earthquakes").table("quakes").insert(
r.http(url)["features"].merge({
"time": r.epoch_time(
r.row['properties']['time'] / 1000
),
"geometry" : r.point(
r.row["geometry"]['coordinates'][0],
r.row["geometry"]['coordinates'][1]
)
}),
conflict="replace").run(conn)
conn.close()
if __name__ == "__main__":
refresh_quakes()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment