Skip to content

Instantly share code, notes, and snippets.

@aausch
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aausch/1a0b3a8bfcffbdb5b9fa to your computer and use it in GitHub Desktop.
Save aausch/1a0b3a8bfcffbdb5b9fa to your computer and use it in GitHub Desktop.
easy to understand, and use, ruby based, contact generator
# 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
}
@fraxedas
Copy link

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

@aausch
Copy link
Author

aausch commented May 16, 2014

thanks1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment