This command-line Python program makes it easy to track household budget expenses and analyze them. The program allows You to easily add new expenses and generate reports.
The purpose of the program is to track Your own expenses and analyze them. You can add, report, import and export expenses right at run the program.
Tanks to this project, I learned how to:
- write definitions with only one responsibility,
- write easy classes using
@dataclass
decorator, - use Python standard library modules: csv, dataclasses, pickle, sys,
- use Python third-party packages like click (Command Line Interface Creation Kit).
- Python - version 3.11.3
- from Python's standard library:
- csv module
- dataclasses module
- pickle module
- sys module
- from Python third-party packages:
- The program has subcommands: add, report, export-python and import-csv:
- add - allows you to add a new expense,
- report - displays all the expenses in the table with total sum,
- import-csv - imports the list of expenses from a CSV file,
- export-python - displays the list of all expenses as an object,
- clear-db - clear database file.
- The program stores a database of all expenses in
data
directory asbudget-database.db
file. If the file does not exist, automatically creates a new empty database in data directory.
I assume You know how to cloning this repository. If not, I refer you to this publication.
Python version should not matter here, although the program was written and tested on version 3.11.3.
If You don't have any Python version, download and install from here.
You can verify Python version by typing in terminal:
$ python --version
Now You need to create and activate virtual environment like this:
$ python -m venv .venv
$ cd .venv\Scripts
$ activate
$ cd ..
$ cd ..
and install click package in the previously created virtual environment:
$ pip install -r requirements.txt
or
$ pip install -U click
You can also install pytest package with dependencies if You want to test my program:
$ pip install -r tests_requirements.txt
or
$ pip install -U pytest
After installation, run the program as shown below.
To add some expense type in terminal like this:
$ python budget_manager.py add 100 "some expense"
To import CSV file with expenses type in terminal:
$ python budget_manager.py import-csv data\expenses.csv
To report expenses, if You have saved in database any:
$ python budget_manager.py report
To display list of all expenses as an Python object:
$ python budget_manager.py export-python
To clear database file:
$ python budget_manager.py clear-db
$ Are You sure? (Y/N): N
- This program was inspired by one of exercises of the Practical Python educational program.
- Many thanks to Krzysztof Mędrela.