Last active
September 12, 2023 21:15
-
-
Save sassafras-bypass/af40f2d5bdccb689942a4cdf898fc4a2 to your computer and use it in GitHub Desktop.
eevee fake data gen
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 | |
from faker import Faker | |
fake = Faker(locale="en_US") | |
def generate_data(num_rows): | |
data = [] | |
for i in range(1, num_rows + 1): | |
acct_no = str(random.randint(100, 9999999999)).zfill(10) | |
acct_name = fake.name() | |
total_balance = random.randint(100, 300000) | |
svc_addr_street = fake.street_address() | |
due_date = fake.future_date(end_date="+1y").strftime("%Y-%m-%d") | |
acct_verification = fake.postcode() | |
promise_plan_balance = random.randint(0, total_balance // 2) if random.random() > .8 else 0 | |
non_owner_permission = "N" | |
past_due_balance = random.randint(0, 300000) | |
acct_type = "R" | |
if (random.random() > .3): | |
mailing_addr_street = svc_addr_street | |
mailing_addr_zip = acct_verification | |
else: | |
mailing_addr_street = fake.street_address() | |
mailing_addr_zip = fake.postcode() | |
phone = fake.phone_number() if random.random() > .5 else None | |
phone_type = random.choice(["CELL", "cell", "landline", "home"]) if phone is not None else None | |
plan_eligible = random.choice(["N", None]) | |
no_contact = random.choice(["Y", "N", None]) | |
email = fake.email() | |
jurisdiction = random.choice(["flareon", "jolteon", "vaporeon", "leafeon"]) | |
balance_data = [acct_no, acct_name, total_balance, svc_addr_street, due_date, acct_verification, promise_plan_balance, non_owner_permission, past_due_balance, acct_type, plan_eligible, jurisdiction] | |
contact_data = [acct_no, acct_name, phone, phone_type, mailing_addr_street, mailing_addr_zip, email, no_contact, jurisdiction] | |
data.append((contact_data, balance_data)) | |
return data | |
def save_to_csv(contact_filename, balance_filename, data): | |
unzipped_data = [list(t) for t in zip(*data)] | |
with open(contact_filename, "w", newline="") as contact_csv: | |
writer = csv.writer(contact_csv) | |
writer.writerow(['acct_no', 'acct_name', 'phone', 'phone_type', 'mailing_addr_street', 'mailing_addr_zip', 'email', 'no_contact', 'state']) | |
writer.writerows(unzipped_data[0]) | |
with open(balance_filename, "w", newline="") as balance_csv: | |
writer = csv.writer(balance_csv) | |
writer.writerow(['acct_no', 'acct_name', 'total_balance', 'svc_addr_Street', 'due_date', 'acct_verification', 'promise_plan_balance', 'non-owner_permission', 'past_due_balance', 'acct_type', 'plan_eligible', 'state']) | |
writer.writerows(unzipped_data[1]) | |
if __name__ == "__main__": | |
num_rows = 1000 | |
data = generate_data(num_rows) | |
save_to_csv("synthetic_customer_contacts.csv", "synthetic_customer_balances.csv", data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment