Skip to content

Instantly share code, notes, and snippets.

@maatthc
Created June 16, 2017 10:28
Show Gist options
  • Save maatthc/02e183d6ebf5ff7681783c95f95083af to your computer and use it in GitHub Desktop.
Save maatthc/02e183d6ebf5ff7681783c95f95083af to your computer and use it in GitHub Desktop.
Generates a file with one random number per line.
#!/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