PYTHON PROJECT
Banking System
import csv
import pandas as pd
import matplotlib.pyplot as plt
import sys
import datetime
found=False
def newAcc():
df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
AccNum=[]
Name=[]
BalAmt=[]
WithAmt=[]
DepositAmt=[]
number=int(input("Enter the number of Account Holder : "))
for i in range(number):
accno=(input("Enter Account Number : "))
name=input("Enter FullName : ")
deposit=(input("Enter Deposit Amount : "))
AccNum.append(accno)
Name.append(name)
BalAmt.append(deposit)
WithAmt.append(0)
DepositAmt.append(deposit)
withAmtdate=['0000:00:00 00:00']
dict={'AccountNumber':AccNum,'Name':Name,'DepositAmount':DepositAmt,'WithdrawAmount': WithAmt, 'BalanceAmount' : BalAmt,'DepositAmtDate': [datetime.datetime.now()],'WithdrawAmtDate':withAmtdate }
df1=pd.DataFrame(dict)
dfNew=df.append(df1,ignore_index=True)
dfNew.to_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
print(dfNew)
def displayRecord():
df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
print(df)
def searchRecord():
df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
accno=int(input("Enter Account Number to be Searched...: "))
print(df[df['AccountNumber'] == accno])
def depositAmt():
found=False
df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
accno=int(input("Enter Account Number : "))
depositamt=int(input("Enter Amount to be Deposited.. : "))
for r,row in df.iterrows():
if (row['AccountNumber'] == accno):
df.at[r,'DepositAmount']= row['DepositAmount']+depositamt
df.at[r,'BalanceAmount'] = row['BalanceAmount'] + depositamt
df.at[r,'DepositAmtDate']=datetime.datetime.now()
found=True
break
if(found==True):
print("Amount Deposited Successfully...")
else:
print("Account Number Invalid.")
df.to_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv",index=False)
print(df[df['AccountNumber']==accno])
def withdrawAmt():
df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
accno=int(input("Enter Account Number : "))
withdrawamt=int(input("Enter Amount to be Withdrawl.. : "))
for r,row in df.iterrows():
if (row['AccountNumber']==accno):
df.at[r,'WithdrawAmount']= withdrawamt
df.at[r,'BalanceAmount'] = row['BalanceAmount'] - withdrawamt
df.at[r,'WithdrawAmtDate']=datetime.datetime.now()
found=True
break
if(found==True):
print("Amount Withdrawl Successfully...")
else:
print("Account Number Invalid.")
df.to_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv",index=False)
print(df[df['AccountNumber']==accno])
def updateRecord():
found=False
df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
accno = int(input("Enter Account Number : "))
for r,row in df.iterrows():
if row['AccountNumber']==accno:
print(df[df['AccountNumber']==accno])
print("You cannot modify the Account Number. ")
pwd=input("To update the record Please enter the password : ")
if(pwd=='Admin'):
newname=input("Enter New Name")
newDepositamt=int(input("Enter Deposit Amount : "))
newWithdrawamt=int(input("Enter Withdrawl Amount : "))
newBalance= newDepositamt-newWithdrawamt
df.at[r,'DepositAmount'] = newDepositamt
df.at[r,'WithdrawAmount']= newWithdrawamt
df.at[r,'BalanceAmount'] = newBalance
found=True
else:
print("Password Invalid.")
if(found==True):
print("Record Updated Successfully...")
else:
print("Account Number Invalid.")
df.to_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv",index=False)
print(df[df['AccountNumber']==accno])
def deleteRecord():
found=False
df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
accno = int(input("Enter Account Number : "))
for r,row in df.iterrows():
if (row['AccountNumber']==accno):
df.drop(df.index[r],axis=0)
found=True
if(found==True):
print("Record Deleted Successfully...")
else:
print("Account Number Invalid.")
df.to_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv",index=False)
def lineGraph():
df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
DepositAmt=[]
WithdrawAmt=[]
BalAmt=[]
name=[]
for c,col in df.iterrows().head(5):
n=col['Name']
ba=col['BalanceAmount']
name.append(n)
BalAmt.append(ba)
plt.plot(name,BalAmt,'r',linewidth=2,linestyle='solid')
plt.xlabel('Customer Name')
plt.ylabel('Balance Amount')
plt.show()
def barGraph():
df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
DepositAmt=[]
WithdrawAmt=[]
BalAmt=[]
name=[]
for r,row in df.iteritems():
DepositAmt=row['DepositAmount']
WithdrawAmt=row['WithdrawAmount']
BalAmt=row['BalanceAmount']
name=row['Name']
found=True
if(found==True):
plt.bar(Name,DepositAmt,'r')
plt.xlabel('Customer Name')
plt.ylabel('Deposit Amount')
plt.show()
else:
print("Invalid Access")
def dataVisual():
print("Data Visualization")
print("Menu\n 1. Line Graph\n 2. Bar Graph \n ")
choice= int(input("Enter your choice"))
if choice==1:
lineGraph()
elif choice==2:
barGraph()
else:
print("Please Enter Correct Choice...")
while True:
print("Banking System")
print("Menu \n 1.Open New Account \n 2.Deposit Amount \n 3.Withdraw Amount \n 4.Update Record\n 5.Dispaly All Record\n 6.Search Record\n 7.Delete Record\n 8.Data Visualization\n 9. Exit ")
choice=int(input("Enter your Choice"))
if choice==1:
newAcc()
elif choice==2:
depositAmt()
elif choice==3:
withdrawAmt()
elif choice==4:
updateRecord()
elif choice==5:
displayRecord()
elif choice==6:
searchRecord()
elif choice==7:
deleteRecord()
elif choice==8:
dataVisual()
elif choice==9:
sys.exit()
else:
sys.exit()
No comments:
Post a Comment