Skip to content

Instantly share code, notes, and snippets.

@blairanderson
Created February 6, 2013 03:12
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 blairanderson/4719918 to your computer and use it in GitHub Desktop.
Save blairanderson/4719918 to your computer and use it in GitHub Desktop.
to create an array of hashes
def parse_file(filename)
@people = []
@contents.each do |row|
person = {}
person[:id] = row[0]
person[:regdate] = row[:regdate]
person[:first_name] = clean_first_name(row[:first_name])
person[:last_name] = clean_last_name(row[:last_name])
person[:email] = clean_email(row[:email_address])
person[:phone] = clean_phone(row[:homephone])
person[:street] = clean_street(row[:street])
person[:city] = clean_city(row[:city])
person[:state] = clean_state(row[:state])
person[:zipcode] = clean_zipcode(row[:zipcode])
@people << person
end
puts "Loaded #{@people.count} Records from '#{filename}'..."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment