Commit 259e6339 authored by Alexander Lercher's avatar Alexander Lercher

Created direct upload for bank-app data

parent 935c80f7
import csv
import hashlib
import sys
import os
modules_paths = ['.', '../../../modules/']
for modules_path in modules_paths:
if os.path.exists(modules_path):
sys.path.insert(1, modules_path)
from messaging.MessageHandler import MessageHandler
# file to read the data from
CSV_FILE = r'dummy_upload/bank_app/bank_data.csv'
handler = MessageHandler()
def upload_transaction(transaction):
uid = hashlib.sha256(f"{transaction['Transaction_ID']}{transaction['Timestamp']}".encode("utf-8")).hexdigest()
transaction['UniqueID'] = uid
transaction['ApplicationType'] = 'bank-app'
transaction['docType'] = 'bank-app'
t = {
'use_case': transaction['ApplicationType'],
'table': transaction['docType'],
'id': uid,
'properties': transaction,
}
handler.handle_new_trace(t)
type_mapping = { 'House Rent': 1, 'Payback Loan': 2, 'Initial Credit': 3, 'Emergency Help': 4, 'Friendly Help': 5 }
if __name__ == '__main__':
with open(CSV_FILE, 'r') as file:
reader = csv.reader(file)
titles = next(reader)
for row in reader:
transaction = {}
for idx in range(len(row)):
transaction[titles[idx]] = row[idx]
transaction['Transaction_Type'] = type_mapping[transaction['Transaction_Type']]
upload_transaction(transaction)
......@@ -3,9 +3,10 @@ import hashlib
import sys
import os
modules_path = '../../../modules/'
if os.path.exists(modules_path):
sys.path.insert(1, modules_path)
modules_paths = ['.', '../../../modules/']
for modules_path in modules_paths:
if os.path.exists(modules_path):
sys.path.insert(1, modules_path)
from messaging.MessageHandler import MessageHandler
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment