· 7 years ago · May 13, 2018, 01:08 PM
1import csv
2import simplegeo
3
4OAUTH_TOKEN = '[insert_oauth_token_here]'
5OAUTH_SECRET = '[insert_oauth_secret_here]'
6CSV_FILE = '[insert_csv_file_here]'
7LAYER = '[insert_layer_name_here]'
8
9client = simplegeo.Client(OAUTH_TOKEN, OAUTH_SECRET)
10
11def insert(data):
12 layer = LAYER
13 id=data.pop("id")
14 lat=data.pop("latitude")
15 lon=data.pop("longitude")
16 # Grab more columns if you wish
17 record = simplegeo.Record(layer,id,lat,lon,**data)
18 client.add_record(record)
19
20r = csv.DictReader(open(CSV_FILE, mode='U'))
21for l in r:
22 insert(l)