/
generator.py
41 lines (33 loc) · 2.12 KB
/
generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
from faker import name
from faker import lorem
import random
import csv
import sys
import time
bools = [True, False]
maxInt = 2147483648
length = 1000000
def main():
headers = ['archived', 'author', 'author_flair_css_class', 'author_flair_text', 'body', 'controversiality',
'created_utc', 'distinguished', 'downs', 'edited', 'gilded', 'id', 'link_id', 'name',
'parent_id', 'retrieved', 'score', 'score_hidden', 'subreddit', 'subreddit_id', 'ups', 'positive']
start_time = time.time()
with open("test_data/test.csv", 'w', newline='', encoding='utf-8') as csv_file:
writer = csv.writer(csv_file, delimiter=',')
writer.writerow(headers)
for i in range(0, length):
row = [random.choice(bools), name.find_name(), '', '', lorem.bias_sentence(False, True), random.randint(-maxInt, maxInt), random.randint(-maxInt, maxInt), '', random.randint(-maxInt, maxInt),
random.choice(bools), random.randint(-maxInt, maxInt), name.find_name()+str(random.randint(-maxInt, maxInt)), name.first_name()+str(random.randint(-maxInt, maxInt)), name.find_name(),
name.last_name()+str(random.randint(-maxInt, maxInt)), random.randint(-maxInt, maxInt), random.randint(-maxInt, maxInt), random.choice(bools), '/r'+name.find_name(),
name.find_name()+str(random.randint(-maxInt, maxInt)), random.randint(-maxInt, maxInt), True]
writer.writerow(row)
for i in range(0, length):
row = [random.choice(bools), name.find_name(), '', '', lorem.bias_sentence(False, False), random.randint(-maxInt, maxInt), random.randint(-maxInt, maxInt), '', random.randint(-maxInt, maxInt),
random.choice(bools), random.randint(-maxInt, maxInt), name.find_name()+str(random.randint(-maxInt, maxInt)), name.first_name()+str(random.randint(-maxInt, maxInt)), name.find_name(),
name.last_name()+str(random.randint(-maxInt, maxInt)), random.randint(-maxInt, maxInt), random.randint(-maxInt, maxInt), random.choice(bools), '/r'+name.find_name(),
name.find_name()+str(random.randint(-maxInt, maxInt)), random.randint(-maxInt, maxInt), False]
writer.writerow(row)
print ("Took " + str(time.time()-start_time) + " seconds.")
if __name__ == "__main__":
main()