Last active
January 14, 2019 11:54
-
-
Save thoroc/02b41385e1ae3296649b2109c0bc17f9 to your computer and use it in GitHub Desktop.
quick solution to get some random data (ids 8 char long between 10100000 and 10800000)
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 inspect | |
def get_frame_info() -> dict: | |
callerframerecord = inspect.stack()[1] | |
frame = callerframerecord[0] | |
info = inspect.getframeinfo(frame) | |
frame_info = {'filename': info.filename, 'function': info.function, 'lineno': info.lineno} | |
return frame_info | |
def generate_ids(filename: str, number_of_ids: int, lower_bound=10100000, upper_bound=10800000): | |
with open(filename, 'w', newline='') as csv_file: | |
spam_writer = csv.writer(csv_file, delimiter=' ', | |
quotechar='|', quoting=csv.QUOTE_MINIMAL) | |
print(f"{get_frame_info()}") | |
for i in range(number_of_ids): | |
_id = "%0.8d" % random.randint(lower_bound, upper_bound) | |
print(f"called from: '{get_frame_info()['function']}' at line: '{get_frame_info()['lineno']}' _id -> '{_id}'") | |
spam_writer.writerow([_id]) | |
generate_ids('data/input/players.csv', 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment