Skip to content

Instantly share code, notes, and snippets.

@chapados
Created October 30, 2008 18:00
Show Gist options
  • Save chapados/21093 to your computer and use it in GitHub Desktop.
Save chapados/21093 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
results = ARGV.shift # input file from cli
measures_full = {'PROP 1A'=>'Safe, Reliable High-Speed Train Bond Act',
'PROP 2' =>'Standards for Confining Farm Animals',
'PROP 3' =>"Children's Hospital Bond Act. Grant Program.",
'PROP 4' =>"Parent Notif. Before Terminating Minor's Pregnancy",
'PROP 5' =>'Nonviolent Drug Offense. Sentencing, Parole, Rehab',
'PROP 6' =>'Police, Law Enforcement Funding. Criminal Laws.',
'PROP 7' =>'Renewable Energy Generation',
'PROP 8' =>"Eliminates Right of Same-Sex Couples to Marry",
'PROP 9' =>"Criminal Justice System. Victims' Rights. Parole.",
'PROP 10'=>'Altern. Fuel Vehicles and Renewable Energy Bonds',
'PROP 11'=>'Redistricting',
'PROP 12'=>"Veterans' Bond"}
measures_byname = measures_full.invert
begin
if results
io = File.open(results, 'r')
else
io = STDIN
end
rescue IOError
puts "couldn't open results"
exit 1
end
fixed_ca =
io.map do |line|
line.strip! # remove extraneous chars at each end
vals = line.split('|')
name = vals.first
line unless measures_byname.has_key?(name)
"#{measures_byname[name]} - #{vals.join("|")}"
end
io.close
props = fixed_ca.find_all { |ca| ca =~ /^PROP/ }
puts "#{fixed_ca.size} entries"
puts "** props **"
props.each { |p| puts p }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment