Created
May 16, 2011 20:36
-
-
Save mager/975315 to your computer and use it in GitHub Desktop.
parse.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import simplegeo | |
import uuid | |
OAUTH_TOKEN = '' | |
OAUTH_SECRET = '' | |
CSV_FILE = 'parks.canada.csv' | |
LAYER = 'co.mager.parks.canada' | |
client = simplegeo.Client(OAUTH_TOKEN, OAUTH_SECRET) | |
def insert(data): | |
layer = LAYER | |
lon=data.pop("lon") | |
lat=data.pop("lat") | |
name=data.pop("name") | |
id=str(uuid.uuid4()) | |
# Grab more columns if you wish | |
record = simplegeo.Record(layer,id,lat,lon,**data) | |
print record | |
client.add_record(record) | |
r = csv.DictReader(open(CSV_FILE, mode='U')) | |
for l in r: | |
insert(l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lon | lat | name | province | |
---|---|---|---|---|
-115.55 | 51.166667 | Banff National Park | Alberta | |
-112.870833 | 53.592778 | Elk Island National Park | Alberta | |
-118.082222 | 52.873056 | Jasper National Park | Alberta | |
-113.915278 | 49.045833 | Waterton Lakes National Park | Alberta | |
-112.986389 | 59.390833 | Wood Buffalo National Park | Alberta | |
-117.518611 | 51.3 | Glacier National Park | British Columbia | |
-123.447778 | 48.850556 | Gulf Islands National Park Reserve | British Columbia | |
-131.471111 | 52.389167 | Gwaii Haanas Park Reserve and Haida Heritage Site | British Columbia | |
-116.049167 | 50.883056 | Kootenay National Park | British Columbia | |
-118.065556 | 51.085833 | Mount Revelstoke National Park | British Columbia | |
-124.769167 | 48.636111 | Pacific Rim National Park Reserve | British Columbia | |
-116.486667 | 51.395278 | Yoho National Park | British Columbia | |
-63.100556 | 58.672222 | Torngat Mountains National Park Reserve | Labrador | |
-100.036111 | 50.863889 | Riding Mountain National Park | Manitoba | |
-92.670278 | 57.246389 | Wapusk National Park | Manitoba | |
-64.953889 | 45.595278 | Fundy National Park | New Brunswick | |
-64.966944 | 46.849722 | Kouchibouguac National Park | New Brunswick | |
-57.783333 | 49.5 | Gros Morne National Park | Newfoundland | |
-53.996111 | 48.511944 | Terra Nova National Park | Newfoundland | |
-119.741389 | 74.0225 | Aulavik National Park | Northwest Territories | |
-123.6 | 61.083333 | Nahanni National Park Reserve | Northwest Territories | |
-123.016667 | 69.283333 | Tuktut Nogait National Park | Northwest Territories | |
-60.811389 | 46.816111 | Cape Breton Highlands National Park | Nova Scotia | |
-65.218333 | 44.399167 | Kejimkujik National Park | Nova Scotia | |
-65.016667 | 67.883333 | Auyuittuq National Park | Nunavut | |
-68.421389 | 81.563889 | Quttinirpaaq National Park | Nunavut | |
-78.434444 | 72.340556 | Sirmilik National Park | Nunavut | |
-87.305556 | 65.341667 | Ukkusiksalik National Park | Nunavut | |
-81.614167 | 45.238889 | Bruce Peninsula National Park | Ontario | |
-79.874722 | 44.877778 | Georgian Bay Islands National Park | Ontario | |
-82.517778 | 41.964167 | Point Pelee National Park | Ontario | |
-85.916389 | 48.033611 | Pukaskwa National Park | Ontario | |
-75.873056 | 44.414444 | St. Lawrence Islands National Park | Ontario | |
-63.075 | 46.416667 | Prince Edward Island National Park | Prince Edward Island | |
-64.290556 | 48.823889 | Forillon National Park | Quebec | |
-72.856111 | 46.808056 | La Mauricie National Park | Quebec | |
-63.576667 | 50.254722 | Mingan Archipelago National Park Reserve | Quebec | |
-107.425833 | 49.176944 | Grasslands National Park | Saskatchewan | |
-106.233611 | 53.995833 | Prince Albert National Park | Saskatchewan | |
-139.525 | 69.519722 | Ivvavik National Park | Yukon | |
-137.510278 | 60.753056 | Kluane National Park and Reserve | Yukon | |
-140.0475 | 68.306944 | Vuntut National Park | Yukon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment