Created
June 16, 2017 10:28
-
-
Save maatthc/02e183d6ebf5ff7681783c95f95083af to your computer and use it in GitHub Desktop.
Generates a file with one random number per line.
This file contains hidden or 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
#!/usr/bin/env python | |
from sys import argv, exit | |
import random | |
big_file_name = "big_file.txt" | |
max_size_of_number = 1000000 | |
random.seed(123) | |
if len(argv) != 2: | |
print "Usage: %s Num_Lines" % __file__ | |
exit() | |
num_lines = int(argv[1]) | |
print "Going to generante big file with %s lines, one random number per line" % (num_lines) | |
big_file = open(big_file_name, "w", 500000) | |
for i in range(0, num_lines): | |
num = random.randint(0,max_size_of_number) | |
big_file.write(str(num) + '\n') | |
big_file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment