Skip to content

Instantly share code, notes, and snippets.

@tatsuosakurai
Created January 9, 2011 07:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatsuosakurai/771507 to your computer and use it in GitHub Desktop.
Save tatsuosakurai/771507 to your computer and use it in GitHub Desktop.
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