Ejemplo n.º 1
0
def rand_date_time():
    date_time = ''
    date_time += '2019'
    date_time += '-'
    month = get_random(1, 12, 1)
    if month < 10:
        date_time += '0'
        date_time += str(month)
    else:
        date_time += str(month)
    date_time += '-'
    day = get_random(0, 29, 1)
    if day < 10:
        date_time += '0'
        date_time += str(day)
    else:
        date_time += str(day)
    date_time += ' '
    hour = get_random(0, 23, 1)
    if hour < 10:
        date_time += '0'
        date_time += str(hour)
    else:
        date_time += str(day)
    date_time += ':'
    min = get_random(0, 59, 1)
    if min < 10:
        date_time += '0'
        date_time += str(min)
    else:
        date_time += str(min)
    date_time += ':'
    sec = get_random(0, 59, 1)
    if sec < 10:
        date_time += '0'
        date_time += str(sec)
    else:
        date_time += str(sec)
    date_time += ':'
    ff = get_random(0, 59, 1)
    if ff < 10:
        date_time += '0'
        date_time += str(ff)
    else:
        date_time += str(ff)

    return date_time
Ejemplo n.º 2
0
import csv
from gen_random import get_random

sec_loans = []
half_counter = 1

with open('./csv/borrower.csv', 'r') as f:

    reader = csv.reader(f, delimiter=',')

    for row in reader:
        half_counter += 1
        if half_counter % 2 == 0:
            sec_loans.append((row[1], get_random(0, 0, 0),
                              get_random(0, 100000, 0), get_random(0, 500, 0)))

with open('./csv/sec_loan.csv', 'w', newline='\n') as f:
    writer = csv.writer(f, delimiter=',')
    for row in sec_loans:
        writer.writerow(row)
    for row in reader:
        half_counter += 1
        if half_counter % 2 == 1:
            card_ids.append(row[1])

with open('./csv/depositor.csv', 'r') as f:

    reader = csv.reader(f, delimiter=',')
    half_counter = 0

    for row in reader:
        half_counter += 1
        if half_counter % 2 == 1:
            acct_ids.append(row[1])

card_counter = 0
for card_id in card_ids:
    if card_counter < len(acct_ids):
        limit = get_random(0, 100000, 0)
        balance = get_random(0, floor(limit), 0)
        balance_due = get_random(0, floor(balance), 0)
        credit_cards.append((card_id, acct_ids[card_counter],
                             get_random(0, 0, 0), limit, balance, balance_due))
        card_counter += 1

with open('./csv/credit_card.csv', 'w', newline='\n') as f:
    writer = csv.writer(f, delimiter=',')
    for row in credit_cards:
        writer.writerow(row)
from gen_random import get_random
from rand_date_time import rand_date_time
from random import gauss

transactions = []
acct_ids = []
timestamps = []

with open('./csv/depositor.csv', 'r') as f:
  
  reader = csv.reader(f, delimiter=',')

  for row in reader:
    acct_ids.append(row[1])
# INSERT INTO table_dt VALUES(3, TIMESTAMP '2003-01-01 00:00:00 US/Pacific');
for i in range( len(acct_ids) * 3):
  timestamps.append( rand_date_time() )



for i in range( len(acct_ids) * 3):

  amount = round(gauss(0, 125), 2)
  transactions.append( (i, int(get_random(1, 65, 1)), timestamps[i], amount) )

with open('./csv/transaction.csv', 'w', newline='\n') as f:
  writer = csv.writer(f, delimiter=',')
  for row in transactions:
    writer.writerow(row)

    reader = csv.reader(f, delimiter=',')

    for row in reader:
        branch_ids.append(row[0])

with open('./csv/depositor.csv', 'r') as f:

    reader = csv.reader(f, delimiter=',')

    for row in reader:
        half_counter += 1
        if half_counter % 2 == 0:
            acct_ids.append(row[1])

branch_counter = 0

for i in range(len(acct_ids)):
    rand_index = get_random(0, abs(len(branch_ids) - 1), 1)
    rand_branch_ids.append(rand_index)

for id in acct_ids:
    balance = get_random(0, 100000, 0)
    savings_accounts.append(
        (id, branch_ids[rand_branch_ids[branch_counter]], balance,
         get_random(0, 0, 0)))
    branch_counter += 1

with open('./csv/savings_accounts.csv', 'w', newline='\n') as f:
    writer = csv.writer(f, delimiter=',')
    for row in savings_accounts:
        writer.writerow(row)
    reader = csv.reader(f, delimiter=',')

    for row in reader:
        branch_ids.append(row[0])

with open('./csv/depositor.csv', 'r') as f:

    reader = csv.reader(f, delimiter=',')

    for row in reader:
        half_counter += 1
        if half_counter % 2 == 1:
            acct_ids.append(row[1])

for i in range(len(acct_ids)):
    rand_index = get_random(0, abs(len(branch_ids) - 1), 1)
    rand_branch_ids.append(rand_index)

branch_counter = 0
for id in acct_ids:
    min_balance = get_random(0, 100, 0)
    balance = get_random(floor(min_balance), 100000, 0)
    checking_accounts.append(
        (int(id), int(branch_ids[rand_branch_ids[branch_counter]]), balance,
         get_random(0, 0, 0), min_balance))
    branch_counter += 1

with open('./csv/checking_account.csv', 'w', newline='\n') as f:
    writer = csv.writer(f, delimiter=',')
    for row in checking_accounts:
        writer.writerow(row)
Ejemplo n.º 7
0
import csv
from gen_random import get_random

debit_cards = []
half_counter = 0

with open('./csv/card_holder.csv', 'r') as f:

    reader = csv.reader(f, delimiter=',')

    for row in reader:
        half_counter += 1
        if half_counter % 2 == 1:
            checking_accounts.append(
                (row[1], get_random(0, 100000, 0), get_random(0, 0, 0)))

with open('./csv/checking_accounts.csv', 'w', newline='\n') as f:
    writer = csv.writer(f, delimiter=',')
    for row in checking_accounts:
        writer.writerow(row)