-
-
Save richard-julien/9cac61bab212da1f3f086d5d31080525 to your computer and use it in GitHub Desktop.
Simple csv generator
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 csv | |
import random | |
import string | |
rows = 15000 | |
columns = 3 | |
print_after_rows = 100000 | |
letters = string.ascii_lowercase | |
def generate_random_row(col): | |
a = [] | |
l = [i] | |
for j in range(col): | |
l.append(''.join(random.choice(letters) for i in range(20))) | |
a.append(l) | |
return a | |
if __name__ == '__main__': | |
f = open('sample.csv', 'w') | |
w = csv.writer(f, lineterminator='\n') | |
for i in range(rows): | |
if i % print_after_rows == 0: | |
print(".", end="", flush=True) | |
w.writerows(generate_random_row(columns)) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment