Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
tork05用メアドをランダムに抽出
require "csv"
MAX = 50
EXISTING = 18
EMAILCOLNUM = 5
DUPLICATE = 1
def create_data
result = []
#csv取得
CSV.foreach("tork05.csv") do |row|
unless row[0] == "No"
result << {:no => row[0], :email => row[EMAILCOLNUM]}
end
end
result
end
def emails
applicants = create_data
@talkers = applicants[EXISTING..applicants.size].inject([]){|r, a| r << a}.sample(MAX - (EXISTING-DUPLICATE))
@untalkers = (applicants - @talkers).delete_if{|u| !u[:email]}
end
emails
p "v(^ ^)vv(^ ^)vv(^ ^)v talker emails v(^ ^)vv(^ ^)vv(^ ^)v "
p @talkers.map{|t| t[:email]}
p "m(_ _)mm(_ _)mm(_ _)m untalker emails m(_ _)mm(_ _)mm(_ _)m "
p @untalkers.map{|t| t[:email]}
p "talkers + untalkers + EXISTING : #{@talkers.size} + #{@untalkers.size} + #{EXISTING} = #{@talkers.size + @untalkers.size + EXISTING }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment