Last active
January 4, 2024 12:14
-
-
Save robkorv/4839a61e3a5877f8ec75e8ffa063548e to your computer and use it in GitHub Desktop.
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 python3 | |
| import argparse | |
| import locale | |
| import pathlib | |
| import faker | |
| import openpyxl | |
| def main(amount): | |
| script_path = pathlib.Path(__file__).resolve().parent | |
| workbook = openpyxl.Workbook() | |
| worksheet = workbook.active | |
| worksheet.append(["firstname", "lastname", "email", "company", "uuid"]) | |
| loc = locale.getlocale()[0] | |
| if loc in faker.config.AVAILABLE_LOCALES: | |
| fake = faker.Faker(loc) | |
| else: | |
| fake = faker.Faker() | |
| for i in range(amount): | |
| worksheet.append( | |
| [ | |
| fake.first_name(), | |
| fake.last_name(), | |
| fake.ascii_safe_email(), | |
| fake.company(), | |
| fake.uuid4(), | |
| ] | |
| ) | |
| file_path = script_path.joinpath(f"fake-participants-{amount}.xlsx") | |
| print(f"writing to {file_path}") | |
| workbook.save(file_path) | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("-a", "--amount", default=10, type=int) | |
| args = parser.parse_args() | |
| main(args.amount) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment