A **Loan Management System** is a simple Python console application that helps store and manage customer loan records for a bank/financial institution. It keeps borrower details in a **CSV file (`loan.csv`)**, making the data lightweight, portable, and easy to inspect/edit.
This project supports:
- adding new customer loan records
- viewing all records
- searching by Customer ID
- modifying existing records
- deleting one record (or all records)
- calculating loan interest & total repayment (simple interest)
Add one or more customers to the system. For each customer, the program captures:
- Customer ID (unique numeric identifier)
- Name (alphabetic words)
- Loan Amount (principal)
- Loan Time (duration in months)
- Interest Rate (percentage)
Records are appended to loan.csv.
Prints all stored customer records in a readable format.
If the file contains only headers (no data), it shows:
No records found. Please add customer records first.
Searches for a single customer record by Customer ID and displays all details. If not found:
Record Not Found!
Updates an existing customer record by Customer ID.
All fields can be changed after validation, and the CSV is rewritten with updated values.
Deletes:
- a specific record by Customer ID, or
- all records by entering
all(case-insensitive)
Calculates interest amount and total repayment for a given Customer ID using simple interest.
The program computes interest using months as time:
interest = (principal * rate * time/12) / 100total_amount = principal + interest
Closes the program gracefully.
All records are stored in loan.csv with the following header:
CUSTOMER IDNAMELOAN AMOUNTLOAN TIMEINTEREST
The system is designed to fail safely and avoid crashing on invalid input.
- Menu choice must be numeric and within 1–7
- Customer ID must be numeric (
isdigit()) - Name must contain only alphabetic words (
split()+isalpha()) - Loan Amount & Interest must be valid decimal numbers (
float()viais_float()) - Loan Time must be numeric (months)
Most operations first check whether records exist (beyond the header) before continuing.
osos.path.exists()→ checks ifloan.csvexistsos.path.getsize()→ checks if file is empty
csvcsv.reader()→ reads CSV rowscsv.writer()→ writes rows back into CSV
-
no_records_check()
Detects whether the CSV file has records beyond the header; prevents operations on empty datasets. -
heading()
Ensuresloan.csvexists and contains column headers. -
is_float(value)
ReturnsTrueifvaluecan be converted to float; elseFalse. -
wrong_input()
Standardized invalid input message + pause. -
data()
Adds customer records after validating all fields. -
display()
Displays all records. -
search()
Finds and prints a record by Customer ID. -
modify()
Updates a record by Customer ID and rewrites the CSV. -
delete()
Removes a record by Customer ID or clears all records usingall. -
calculate_interest()
Retrieves a record and calculates interest + total repayment.
- Python 3.x
python loan_management_system.pythe program will create
loan.csvif missing
Made with ❤️ by empirea9