Last active
November 15, 2016 23:11
-
-
Save jmitchell/6ba20ebf1201aa782eac42d67e8ce41a to your computer and use it in GitHub Desktop.
Creates tab-separated file of US Senator info from XML (see http://www.senate.gov/general/contact_information/senators_cfm.xml and https://docs.google.com/spreadsheets/d/1ptsPdx5CMM-QuCBh42r7JaGGHE5AMwsWfQ8jEGQBFtk/edit#gid=730682722)
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
#!/usr/bin/env python | |
import xml.etree.ElementTree as ET | |
tree = ET.parse("senators_cfm.xml") | |
root = tree.getroot() | |
for member in root.findall("member"): | |
first_name = member.find("first_name").text | |
last_name = member.find("last_name").text | |
state = member.find("state").text | |
phone = member.find("phone").text | |
website = member.find("website").text | |
print "%s %s\t%s\tSenator\t%s\t%s" % (first_name, last_name, state, phone, website) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment