-
Notifications
You must be signed in to change notification settings - Fork 0
/
random-gen.py
46 lines (32 loc) · 881 Bytes
/
random-gen.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
42
43
44
45
import random
import string
# import argparse
from sys import getsizeof
def _gen_random(size):
"""
Generate a random set of integers that totals to size `size`
"""
# Return file
ret = []
while getsizeof(ret) <= size:
num = (str(random.randint(-2147483648, 2147483647)) + '\n')
ret += [num]
return ret
def main():
"""
Do the things
"""
# parser = argparse.ArgumentParser()
# parser.add_argument('-o', '--output-file', action='store', dest='o')
# TODO: sys.argv these bad boys
size = 100
filepath = 'test.txt'
to_file = _gen_random(size)
lines = 0
with open(filepath, 'w') as outfile:
for line in to_file:
lines += 1
outfile.write(str(line))
print('File written of size %d in %d lines' % (size, lines))
if __name__ == '__main__':
main()