A simple Python-based expense tracking tool that helps you log, categorize, and visualize your expenses through an interactive CLI interface.
- Interactive command-line interface
- Track expenses with date, amount, category, and description
- CSV-based storage for easy data portability
- Calculate totals by category
- Visualize expenses through:
- Pie charts showing expense distribution by category
- Timeline plots showing expenses over time
- Python 3.x
- matplotlib (for visualizations)
# Clone repository
git clone https://github.com/PierrunoYT/expense-tracker.git
cd expense-tracker
# Create and activate virtual environment
python -m venv venv
.\venv\Scripts\activate
# Install dependencies
pip install matplotlib
# Clone repository
git clone https://github.com/PierrunoYT/expense-tracker.git
cd expense-tracker
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip3 install matplotlib
# Install Python if needed
sudo apt-get update
sudo apt-get install python3 python3-pip python3-venv
# Clone repository
git clone https://github.com/PierrunoYT/expense-tracker.git
cd expense-tracker
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip3 install matplotlib
Windows:
.\venv\Scripts\activate
python main.py
macOS/Linux:
source venv/bin/activate
python3 main.py
Once running, the following commands are available:
add - Add a new expense
list - List all expenses
totals - Show totals by category
viz pie - Show pie chart of expenses
viz timeline - Show timeline of expenses
help - Show available commands
exit - Exit the program
The expenses are stored in a CSV file with the following format:
date;amount;category;description
14.01.2025;20;food;test
from expense_tracker import ExpenseTracker
from visualize import plot_expenses_by_category, plot_expenses_timeline
# Create a tracker instance
tracker = ExpenseTracker()
# Add an expense
tracker.add_expense(
amount=50.00,
category="Groceries",
description="Weekly shopping",
date="14.01.2025" # Optional, defaults to current date
)
# Get all expenses
expenses = tracker.get_expenses()
# Get totals by category
totals = tracker.get_total_by_category()
# Create visualizations
plot_expenses_by_category(tracker)
plot_expenses_timeline(tracker)
main.py
: Interactive CLI interfaceexpense_tracker.py
: Core expense tracking functionalityvisualize.py
: Visualization functions using matplotlibinit_expenses.py
: Helper script to initialize expenses fileexpenses.csv
: Data storage file (auto-generated, git-ignored)
- If you get "python not found", ensure Python is added to your PATH
- Use
python
instead ofpython3
for commands
- Use
python3
instead ofpython
for commands - If matplotlib fails:
echo "backend: TkAgg" > ~/.matplotlib/matplotlibrc
- If matplotlib fails, install required system packages:
sudo apt-get install python3-tk
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'feat: add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.