Skip to content

Commit

Permalink
Merge pull request #190 from JuanitaCathy/master
Browse files Browse the repository at this point in the history
Python Script for Expense Tracker
  • Loading branch information
DhanushNehru authored Oct 22, 2023
2 parents 8f3f8cb + 68d8be7 commit befd10a
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Expense Tracker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Expense tracker

### Usage

Install the required dependencies using pip:

```
pip install -r requirements.txt
```

Run the expense.py file to start the bot:

```
python expense.py
```
50 changes: 50 additions & 0 deletions Expense Tracker/expense.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import csv
import os

CSV_FILE = "expenses.csv"

def initialize_csv():
if not os.path.exists(CSV_FILE):
with open(CSV_FILE, "w", newline="") as file:
writer = csv.writer(file)
writer.writerow(["Date", "Description", "Amount"])

def add_expense(date, description, amount):
with open(CSV_FILE, "a", newline="") as file:
writer = csv.writer(file)
writer.writerow([date, description, amount])

def view_expenses():
with open(CSV_FILE, "r") as file:
reader = csv.reader(file)
for row in reader:
print(", ".join(row))

if __name__ == "__main__":
initialize_csv()

while True:
print("\nExpense Tracker Menu:")
print("1. Add Expense")
print("2. View Expenses")
print("3. Exit")

choice = input("Enter your choice: ")

if choice == "1":
date = input("Enter the date (YYYY-MM-DD): ")
description = input("Enter the description: ")
amount = input("Enter the amount: ")

add_expense(date, description, amount)
print("Expense added successfully!")

elif choice == "2":
print("Expenses:")
view_expenses()

elif choice == "3":
break

else:
print("Invalid choice. Please try again.")
2 changes: 2 additions & 0 deletions Expense Tracker/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
csv
os
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ More information on contributing and the general code of conduct for discussion
| Digital Clock | [Digital Clock](https://github.com/DhanushNehru/Python-Scripts/tree/master/Digital%20Clock) | A Python script to preview a digital clock in the terminal. |
| Duplicate Finder | [Duplicate Finder](https://github.com/DhanushNehru/Python-Scripts/tree/master/Duplicate%Fnder) | The script identifies duplicate files by MD5 hash and allows deletion or relocation. |
| Display Popup Window | [Display Popup Window](https://github.com/DhanushNehru/Python-Scripts/tree/master/Display%20Popup%20Window) | A Python script to preview a GUI interface to user. |
| Expense Tracker | [Expense Tracker](https://github.com/DhanushNehru/Python-Scripts/tree/master/Expense%20Tracker) | A Python script which can track expenses. |
| Face Reaction | [Face Reaction](https://github.com/DhanushNehru/Python-Scripts/tree/master/Face%20Reaction) | A script which attempts to detect facial expressions. |
| Fake Profiles | [Fake Profiles](https://github.com/DhanushNehru/Python-Scripts/tree/master/Fake%20Profile) | Create fake profiles. |
| File Encryption Decryption | [File Encryption Decryption](https://github.com/DhanushNehru/Python-Scripts/tree/master/File%20Encryption%20Decryption) | Encrypts and Decrypts files using AES Algorithms for Security purposes. |
Expand Down

0 comments on commit befd10a

Please sign in to comment.