Last active
August 29, 2015 14:01
-
-
Save aausch/1a0b3a8bfcffbdb5b9fa to your computer and use it in GitHub Desktop.
easy to understand, and use, ruby based, contact generator
This file contains hidden or 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
# Copyright 2014, Alex Ausch | |
# Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/ | |
puts ARGV.count | |
if ARGV.count < 1 | |
puts "Missing argument - number of contacts" | |
exit | |
end | |
first_name = "First" | |
last_name = "Last" | |
domain = "invalid.domain" | |
if ARGV.count == 4 | |
first_name = ARGV[1] | |
last_name = ARGV[2] | |
domain = ARGV[3] | |
end | |
email_address = first_name + "." + last_name | |
puts "attempting to generate file for " + ARGV[0] + " contacts ("+ARGV[0]+"contacts.csv) - with first name: " + first_name + " and last name: " + last_name | |
contact_count = Integer(ARGV[0]) | |
File.open(ARGV[0]+"contacts.csv", 'w') { |f| | |
f.write("id,first name, last name, email\n") | |
for i in 1..contact_count do | |
f.write(i.to_s + "," + i.to_s + first_name + "," + last_name + i.to_s + ","+email_address + i.to_s + "\@"+domain+"\n") | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for i in 1..contact_count do
f.write("" + i.to_s + "," + i.to_s + first_name + "," + last_name + i.to_s + ","+email_address + i.to_s + "@"+domain+"\n")
end
That will generate the id field