Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# ksp-submission
This repository is created for Karnataka State Police Hackathon 2023 - submission collection.
## Team Information
### Team Name -
### Problem Statement -
### Team Name - ForeverYoung
### Problem Statement - Bank Account Analysis



#### Sorry Can't Share Personal Work! :(



Empty file added analysis.py
Empty file.
8 changes: 8 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from flask import Flask, request, render_template
import pandas as pd
import re

app = Flask(__name__)

if __name__ == '__main__':
app.run(debug=True)
52 changes: 52 additions & 0 deletions app1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from flask import Flask, request, render_template
import pandas as pd
import re

app = Flask(__name__)


@app.route("/", methods=['GET', 'POST'])
def index():
if request.method == 'POST':
file = request.files["file"]
df = pd.read_excel(file)
return render_template("index.html")

return render_template("index.html")


@app.route("/analysis", methods=['GET', 'POST'])
def analysis():
return render_template("userDetails.html")


@app.route('/upi')
def upi():

return render_template('upi.html')


@app.route('/neft')
def neft():

return render_template('neft.html')


@app.route('/imps')
def imps():

return render_template('imps.html')


@app.route('/userDetails')
def userDetails():
return render_template('userDetails.html')


@app.route('/others')
def others():
return render_template('others.html')


if __name__ == '__main__':
app.run(debug=True)
111 changes: 111 additions & 0 deletions dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@

import pandas as pd
import re
import openpyxl


def upi():
df = pd.read_excel("transactions_2023_02_04_21_23_25.xlsx")
data_list = df[df.columns[2]].tolist()
date = df[df.columns[1]].tolist()
reference = df[df.columns[3]].tolist()
debit = df[df.columns[4]].tolist()
credit = df[df.columns[5]].tolist()
balance = df[df.columns[6]].tolist()

transactionType = []
TransactionAnalyser = []

transaction_categories = {
"UPI": {"count": 0, "details_map": {}},
"ATM": {"count": 0, "details_map": {}},
"debit card": {"count": 0, "details_map": {}},
"NEFT": {"count": 0, "details_map": {}},
"IMPS": {"count": 0, "details_map": {}},
}

for i in range(0, len(data_list)):
data = data_list[i]

# UPI
if "UPI" in data:
first_index = data.index("/")
second_index = data.index("/", first_index + 1)

if "/" in data[second_index + 1:]:
start_index = data.index("/", second_index + 1) + 1
else:
start_index = second_index + 1

end_index = data.rindex("/")
result = data[start_index:end_index]
transaction_categories["UPI"]["count"] += 1
if result in transaction_categories["UPI"]["details_map"]:
transaction_categories["UPI"]["details_map"][result] += 1
else:
transaction_categories["UPI"]["details_map"][result] = 1
TransactionAnalyser.append(result)

# ATM
elif "ATM" in data:
result = data.split("-")[1].strip()
transaction_categories["ATM"]["count"] += 1
if result in transaction_categories["ATM"]["details_map"]:
transaction_categories["ATM"]["details_map"][result] += 1
else:
transaction_categories["ATM"]["details_map"][result] = 1
TransactionAnalyser.append(result)

# Debit Card
elif "debit card" in data:
result = data.split("-")[1].strip()
transaction_categories["debit card"]["count"] += 1
if result in transaction_categories["debit card"]["details_map"]:
transaction_categories["debit card"]["details_map"][result] += 1
else:
transaction_categories["debit card"]["details_map"][result] = 1
TransactionAnalyser.append(result)

# NEFT
elif "NEFT" in data:
result = data.split("-")[1].strip()
transaction_categories["NEFT"]["count"] += 1
if result in transaction_categories["NEFT"]["details_map"]:
transaction_categories["NEFT"]["details_map"][result] += 1
else:
transaction_categories["NEFT"]["details_map"][result] = 1
TransactionAnalyser.append(result)

# IMPS
elif "IMPS" in data:
result = data.split("-")[1].strip()
transaction_categories["IMPS"]["count"] += 1
if result in transaction_categories["IMPS"]["details_map"]:
transaction_categories["IMPS"]["details_map"][result] += 1
else:
transaction_categories["IMPS"]["details_map"][result] = 1
TransactionAnalyser.append(result)

headers = ["Date", "TransactionType", "Details",
"Reference", "Debit", "Credit", "Balance"]
data = [date, transactionType, TransactionAnalyser,
reference, debit, credit, balance]

# Create a new workbook object
workbook = openpyxl.Workbook()

# Create a new sheet in the workbook
sheet = workbook.active
sheet.title = "My Sheet"

# Fill headers
for i, header in enumerate(headers):
sheet.cell(row=1, column=i+1, value=header)

# Fill data
for k, row_data in enumerate(data):
for j, cell_data in enumerate(row_data):
sheet.cell(row=j+2, column=k+1, value=cell_data)

# Save the workbook to a file
workbook.save("new_file3.xlsx")
Binary file added new_file.xlsx
Binary file not shown.
Binary file added new_file1.xlsx
Binary file not shown.
12 changes: 12 additions & 0 deletions static/css/bootstrap.min.css

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions templates/analysis.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<html>
<head>
<title>Multiple Tabs Example</title>
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand" href="{{ url_for('index') }}">HOME</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarColor01">
<ul class="navbar-nav me-auto">
<li class="nav-item">
<a class="nav-link active" href="{{ url_for('userDetails') }}">User Details
<span class="visually-hidden">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('upi') }}">UPI</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('neft') }}">NEFT</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('imps') }}">IMPS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('debit') }}">Debit</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('atm') }}">ATM</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('others') }}">Other</a>
</li>

</ul>
</div>
</div>
</nav>
<div id="content">
{% block content %}
{% endblock %}
</div>
</body>
</html>
33 changes: 33 additions & 0 deletions templates/atm.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% extends "analysis.html" %}

{% block content %}
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
<h2>Immediate Payment Service(IMPS)</h2>
<table id="transactions" class="display">
<p>The total ATM transactions {{ ATM1 }}</p>
<p>
Frequency
</p>
<thead>
<tr class="table-light">
<th scope="row">Connection</th>
<th scope="row">Freuqnecy</th>
</tr>
</thead>

<tbody>
{% for name in matm1 %}
<tr class="table-light">
<td>{{ name }}</td>
<td>{{ matm1[name] }}</td>
</tr>
{% endfor %}
</tbody>
</table>

{% endblock %}
33 changes: 33 additions & 0 deletions templates/debit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% extends "analysis.html" %}

{% block content %}
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
<h2>Immediate Payment Service(IMPS)</h2>
<table id="transactions" class="display">
<p>The total Debit transactions {{ DEBIT1 }}</p>
<p>
Frequency
</p>
<thead>
<tr class="table-light">
<th scope="row">Connection</th>
<th scope="row">Freuqnecy</th>
</tr>
</thead>

<tbody>
{% for name in mdebit1 %}
<tr class="table-light">
<td>{{ name }}</td>
<td>{{ mdebit1[name] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

3 changes: 3 additions & 0 deletions templates/dummy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>
This isnt the correct page! So long.. find the error n solve it!
</h1>
32 changes: 32 additions & 0 deletions templates/imps.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% extends "analysis.html" %}

{% block content %}
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
<h2>Immediate Payment Service(IMPS)</h2>
<table id="transactions" class="display">
<p>The total IMPS transactions {{ IMPS1 }}</p>
<p>
Frequency
</p>
<thead>
<tr class="table-light">
<th scope="row">Connection</th>
<th scope="row">Freuqnecy</th>
</tr>
</thead>

<tbody>
{% for name in mimps1 %}
<tr class="table-light">
<td>{{ name }}</td>
<td>{{ mimps1[name] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
45 changes: 45 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<html>
<head>
<title>Excel File Upload</title>
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
</head>
<body>
<center>
<div class="card text-white bg-primary mb-3 " style="max-width: 50rem; ">
<h1 class="card-header">Upload Excel File</h1>
<div class="card-body">
<form action="/analysis" method="post" enctype="multipart/form-data">
<div>
<div class="form-group">
<label for="formFile" class="form-label mt-4" >Excel file Required:</label>
</div>
<div class = "dropzone">
<input class="form-control" type="file" id="file " accept=".xlsx, .xlsm, .xltx, .xltm, .xls" required />
</div>
</div>
<br>
<div>
<input type="submit" value="Submit" class="btn btn-primary"/>
</div>
</form>
</div>
</div>
</center>
<!--
{% if column1 %}
<h2>Column 1 data</h2>
<ul>
{% for item in column1 %}
<li>{{ item }}</li>
{% endfor %}
</ul>
<h2>Column 2 data</h2>
<ul>
{% for item in column2 %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{% endif %}
-->
</body>
</html>
Loading