Python Personal Finance Tracker

Jul 12, 2024

Python Personal Finance Tracker Project

Introduction

  • Aimed at mastering Python skills.
  • Covers Python syntax, advanced features, and popular modules.
  • Builds a personal finance tracker to log transactions, organize them, get summaries, and plot data.

Project Overview

  • Functions: Add transactions, view summaries, visualize data.
  • Data stored in CSV files for easy import to Excel/Google Sheets.
  • Example features include date-based entries, viewing summaries, and plotting income/expenses.

Setting Up

  • Create a folder personal_finance_tracker_tutorial and open it in Visual Studio Code.
  • Install necessary modules: matplotlib and pandas.
  • Use pip install matplotlib and pip install pandas.
  • Requirements file available for necessary modules.

Files Structure

  • Main files: main.py and data_entry.py.
  • CSV file as the database.
  • Functions in data_entry.py for user data collection.

Implementing Features

Initialize CSV

  • Class CSV with methods to handle CSV operations.
  • Method: initialize_csv(): Check and create CSV file if not found. Defines columns: Date, Amount, Category, Description.

Adding Entries

  • Method: add_entry(date, amount, category, description).
  • Uses CSV writer to append entries.

User Input Functions

  • Data collection functions in data_entry.py.
  • Functions: get_date(), get_amount(), get_category(), get_description().
  • Each function uses input validation.

Main Flow

  • Import data collection functions in main.py.
  • Define main functions to handle user choices and call respective methods for adding/viewing transactions.
  • User choices:
    1. Add new transaction
    2. View transactions within a date range
    3. Exit

Viewing Transactions

  • Method: get_transactions(start_date, end_date).
  • Reads CSV and filters data based on date range.
  • Generates and prints transaction summaries including total income, expenses, and net savings.

Plotting Data

  • Method: plot_transactions(df).
  • Uses matplotlib to visualize data.
  • Steps: Resample data, sum amounts, reindex, plot data.
  • Configurable plot features like labels, title, and grid.

Final Integration

  • Main loop in main() to handle user input and display choices interactively.
  • Calling plot_transactions based on user preference to visualize data.
  • Testing with sample data to ensure functionality.

Advanced Features and Closing

  • Introduced advanced Python features and modules like Matplotlib and Pandas.
  • Demonstrated practical application development.
  • Code available online, suitable for extending into a full-feature project.
  • Encouraged to experiment and build upon the foundation.