Created
January 9, 2011 07:13
-
-
Save tatsuosakurai/771507 to your computer and use it in GitHub Desktop.
tork05用メアドをランダムに抽出
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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