Created
October 1, 2012 11:39
-
-
Save ayushgoel/3811112 to your computer and use it in GitHub Desktop.
Create random contacts CSV
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
import random | |
# Change this number to get more contacts | |
number_of_contacts = 100 | |
# Give FileName here | |
filename = 'contacts.csv' | |
all_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' | |
def create_number(): | |
return ''.join([str(random.randint(0,9)) for i in range(10)]) | |
def get_name(length): | |
return ''.join([all_chars[random.randint(0,len(all_chars)-1)] for i in range(length)]) | |
if __name__ == '__main__': | |
with open(filename, 'w') as f: | |
f.write('First Name,Second Name,Phone\n') | |
for i in range(number_of_contacts): | |
f.write(get_name(5) + ',' + get_name(5) + ',' + create_number() + '\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment