Closed rkiddy closed 9 years ago
I did a quick & dirty hack to test the code you have provided.
from overpy import Overpass
api = Overpass()
result = api.query('relation'
'["boundary"="administrative"]'
'(32.0,-125.0,42.0,-114.0);'
'out body;')
for relation in result.relations:
print('%s\t%s\t%s\t%s\t%s\t%d' % (relation.tags.get('name','').encode('utf8'),
relation.tags.get('admin_level','').encode('utf8'),
relation.tags.get('place','').encode('utf8'),
relation.tags.get('boundary','').encode('utf8'),
relation.tags.get('type','').encode('utf8'),
relation.id))
Looks like one argument is missing in your format string.
Your string
%s\t%s\t%s\t%s\t%s
Modified version
%s\t%s\t%s\t%s\t%s\t%d
I am pretty sure that was just a typo. Sorry.
Um. Nope. Pilot error. Sorry.
You are welcome.
I am trying to go through a large set of relations, specifically all those in California.
My python is not very sophisticated. I am a almost-intermediate in the language. I have the list of relations and am trying to print this out:
Everything but the id works great. I have tried writing out the id with "%d" and that does not work, but with "%s", it says it is a number. Looking at your recent edit, it might be None. How can one write this out?