Created
July 11, 2015 21:35
-
-
Save konklone/6c9739997f3835f41309 to your computer and use it in GitHub Desktop.
get domains from legislators file
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 ruby | |
require 'yaml' | |
require 'csv' | |
require 'uri' | |
legislators = YAML.load_file("legislators-current.yaml") | |
CSV.open("house.csv", "w") do |house| | |
CSV.open("senate.csv", "w") do |senate| | |
legislators.each do |leg| | |
puts "[#{leg['id']['bioguide']}] Processing..." | |
term = leg['terms'].last | |
row = [] | |
if term['url'] | |
url = URI(term['url']).hostname.sub(/^www./, '') | |
row += [url] | |
else | |
puts "NO URL?!" | |
end | |
if leg['name'] | |
row += [leg['name']['last'], leg['name']['first']] | |
end | |
if term['type'] == 'sen' | |
senate << row | |
else | |
house << row | |
end | |
end | |
end | |
end | |
puts "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment