Skip to content

Commit

Permalink
chore: include script to generate customers and txns
Browse files Browse the repository at this point in the history
  • Loading branch information
v3g42 committed Feb 3, 2024
1 parent 4ccf4e6 commit 9849b05
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 0 deletions.
52 changes: 52 additions & 0 deletions sinks/aerospike/generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from faker import Faker
import csv
import random
from tqdm import tqdm

fake = Faker()

# Generate customers data
customers = []
for i in tqdm(range(100000)): # Generate 100 customers
customer = [
i, # Assuming customer_id starts at 0
fake.first_name(),
fake.last_name(),
fake.date_of_birth(minimum_age=18, maximum_age=90).isoformat(),
fake.email(),
fake.phone_number(),
fake.address().replace('\n', ', '), # Replace newlines in address
fake.city(),
fake.state(),
fake.zipcode(),
fake.country(),
]
customers.append(customer)

print("customers completed")
# Write customers to CSV
with open('customers.csv', 'w', encoding='utf-8') as file:
writer = csv.writer(file, delimiter=',', lineterminator='\r\n', quoting=csv.QUOTE_NONNUMERIC)
writer.writerow(['customer_id', 'first_name', 'last_name', 'dob', 'email', 'phone_number', 'address', 'city', 'state', 'zip_code', 'country'])
writer.writerows(customers)

# Generate transactions data
transactions = []
for i in tqdm(range(5000000)): # Generate 500 transactions
transaction = [
i, # Assuming transaction_id starts at 0
random.randint(0, len(customers)), # Assuming customer IDs range from 0 to 99
random.choice(['Deposit', 'Withdrawal', 'Transfer']),
round(random.uniform(10.00, 10000.00), 2),
'USD',
fake.date_this_year().isoformat(),
random.choice(['Completed', 'Pending', 'Cancelled']),
fake.sentence(),
]
transactions.append(transaction)

# Write transactions to CSV
with open('transactions.csv', 'w', encoding='utf-8') as file:
writer = csv.writer(file, delimiter=',', lineterminator='\r\n', quoting=csv.QUOTE_NONNUMERIC)
writer.writerow(['transaction_id', 'customer_id', 'type', 'amount', 'currency', 'transaction_date', 'status', 'description'])
writer.writerows(transactions)
76 changes: 76 additions & 0 deletions sinks/aerospike/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions sinks/aerospike/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.poetry]
name = "aerospike"
version = "0.1.0"
description = ""
authors = ["VG <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"
faker = "^22.6.0"
tqdm = "^4.66.1"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

0 comments on commit 9849b05

Please sign in to comment.