Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote branch 'origin/master'

  • Loading branch information...
commit 023c46771dd16381f55bda09dde343525d14f0bd 2 parents 612e114 + ea641ea
Schuyler Erle authored
Showing with 13 additions and 6 deletions.
  1. +2 −2 geocrawlr.py
  2. +11 −4 leaves_from_woeid.py
4 geocrawlr.py
View
@@ -1,8 +1,8 @@
import Flickr.API
import json, time, sys
-FLICKR_KEY = "250312a2c0a1a34bae889d5a6b5c07e0"
-FLICKR_SECRET = "ff91efe4924c0461"
+FLICKR_KEY = ""
+FLICKR_SECRET = ""
START_PAGE = 1
END_PAGE = 10
15 leaves_from_woeid.py
View
@@ -13,11 +13,15 @@
def main():
woeid = sys.argv[1]
+ leaftype = "Suburb"
+ if len(sys.argv) > 2:
+ leaftype = "'%s'" % sys.argv[2]
+
outfile = "leaves_%s.csv" % woeid
childq = """select * from woe_places
where parent_id = %s
- and placetype in ('LocalAdmin','Suburb')"""
+ and placetype in ('County','LocalAdmin','Suburb')"""
conn_string = "dbname='hood'"
# get a connection, if a connect cannot be made an exception will be raised here
@@ -27,22 +31,25 @@ def main():
search = set([woeid])
leaves = set()
names = {}
+ types = {}
while len(search) > 0:
curr_search = copy.copy(search)
for woe in curr_search:
search.remove(woe)
- qry = childq % woe
+ qry = childq % (woe, leaftypes)
cursor.execute(qry)
if cursor.rowcount == 0:
- leaves.add((names[woe],woe))
+ if types[woe] == leaftype:
+ leaves.add((names[woe],types[woe],woe))
for line in cursor:
names[line['woe_id']] = line['name']
+ types[line['woe_id']] = line['placetype']
search.add(line['woe_id'])
conn.close()
owriter = csv.writer(open(outfile, 'w'))
- owriter.writerow(["name","woe_id"])
+ owriter.writerow(["name","type","woe_id"])
for leaf in leaves:
owriter.writerow(leaf)
Please sign in to comment.
Something went wrong with that request. Please try again.