Skip to content

Instantly share code, notes, and snippets.

@robkorv
Last active January 4, 2024 12:14
Show Gist options
  • Select an option

  • Save robkorv/4839a61e3a5877f8ec75e8ffa063548e to your computer and use it in GitHub Desktop.

Select an option

Save robkorv/4839a61e3a5877f8ec75e8ffa063548e to your computer and use it in GitHub Desktop.
#!/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