Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'csv'
CSV.foreach('app/services/rg_list.csv', headers: true) do |row|
Person.find_or_create_by name: row['Name'].to_s.split.map(&:capitalize).join(' '), email: row['Email'].to_s.downcase, gender: row['Gender'].to_s.downcase
end
CSV.foreach('app/services/rg17_register_full.csv', headers: true) do |row|
Person.find_or_create_by name: row['Name'].to_s.split.map(&:capitalize).join(' '), email: row['Email'].to_s.downcase.strip, gender: row['Gender'].to_s.downcase, register_date: row['register_date'].to_s.downcase, birth_date: row['birth_date'].to_s, phone: row['phone'].to_s.downcase.strip, level: row['level'].to_s.downcase, motivation: row['motivation'].to_s.downcase, heard_ror: row['heard_ror'].to_s.downcase, laptop: row['laptop'].to_s.downcase, so: row['so'].to_s.downcase, expectation: row['expectation'].to_s.downcase, how_did_you_find_it: row['how_did_you_find_it'].to_s.downcase
end
CSV.foreach('app/services/rg17_confirmation_1.csv', headers: true) do |row|
Person.where(email: row['email'].to_s.downcase.strip).update_all(days: row['days'].to_s.downcase)
Person.where(email: row['email'].to_s.downcase.strip).update_all(tshirt_size: row['tshirt_size'].to_s)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment