Skip to content

Instantly share code, notes, and snippets.

@geojackass
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geojackass/11376234 to your computer and use it in GitHub Desktop.
Save geojackass/11376234 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
#!coding: utf-8
from BeautifulSoup import BeautifulStoneSoup
doc = open('watersupplysites.xml')
soup = BeautifulStoneSoup(''.join(doc))
for ln in soup:
name = soup.findAll('name')
ward = soup.findAll('ward')
addr = soup.findAll('address')
lat = soup.findAll('latitude')
lng = soup.findAll('longitude')
wsslist = open('wsslist.csv', 'w')
i = 0
while i < len(name):
i += 1
j = i - 1
print i
wslist = name[j].string + "," + ward[j].string + " " + addr[j].string + "," + lat[j].string + "," + lng[j].string + '\n'
wslist_u = wslist.encode('utf-8')
print wslist_u
wsslist.write(wslist_u)
#count as debug print 20140427@Shoichi
print i
#count as debug print 20140427@Shoichi
print name[j]
wsslist.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment