Skip to content

Instantly share code, notes, and snippets.

@jcasimir
Forked from anonymous/gist:926564
Created April 19, 2011 00:16
Show Gist options
  • Save jcasimir/926572 to your computer and use it in GitHub Desktop.
Save jcasimir/926572 to your computer and use it in GitHub Desktop.
require "rubygems"
require "fastercsv"
class SalAttend
attr_accessor :file
attr_accessor :headers
# Added the parameter here...
def initialize(filename)
puts "JSAttend Initialized"
# and call the open_file method here...
open_file(filename)
end
def open_file(filename)
puts "Trying to open the file with FasterCSV"
@file = FasterCSV.open(filename, {:headers => true, :return_headers => true, :header_converters => :symbol})
@headers = @file.readline
end
def print_names
@file.each do |line|
puts line[:first_name] + " " + line[:last_name]
end
end
end
# Then you'll have to specify the filename here...
jsa = SalAttend.new("event_attendees.csv")
jsa.print_names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment