Skip to content

Instantly share code, notes, and snippets.

@zacharyc
Created May 1, 2012 15: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 zacharyc/2568583 to your computer and use it in GitHub Desktop.
Save zacharyc/2568583 to your computer and use it in GitHub Desktop.
Cheerleader CSV Parser
#!/Users/zacharyc/.rvm/rubies/ruby-1.9.2-head/bin/ruby
# This script assumes there is a folder named ./emails for the content to go into
require 'csv'
#load the cheerleaders
file = CSV.read("team.csv")
print file.class
cheerleaders = []
for i in 1..(file.length - 1)
cheerleaderInfo = {}
column = 0
for header in file[0]
cheerleaderInfo[header] = file[i][column]
column += 1
end
cheerleaders[i-1] = cheerleaderInfo
end
for cheerleader in cheerleaders
msg = cheerleader["Email "] + "\n\n"
filename = cheerleader["First Name"] + cheerleader["Last Name"] + ".txt"
File.open( "emails/"+filename, "w" ) do |the_file|
the_file.puts msg
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment