๐ŸŽ™ Free live masterclass ยท Sun, 29 Nov, 7:00 pm IST ยท Java Full Stack roadmap Register free โ†’
Skills101

Personal expense tracker with charts

Log daily spending by category, see monthly totals and draw a pie chart of where the money went.

Beginnerโฑ 5โ€“8 hours๐Ÿชœ 7 stepsPythonCSVmatplotlib

What you'll learn

  • โ—†The csv module and dates
  • โ—†Grouping and summing data
  • โ—†Drawing charts with matplotlib

What you'll build

  • โœ“Add an expense (amount, category, note, date)
  • โœ“Monthly summary by category
  • โœ“Budget limit warnings
  • โœ“Pie and bar charts saved as PNG

Step-by-step guide

  1. 1

    Pick the file format

    Use expenses.csv with columns date,amount,category,note. Create it with a header row if missing.

  2. 2

    Add expenses

    Ask for amount (validate it is a positive number), category from a fixed list, optional note; default date is today.

  3. 3

    Read and filter by month

    Read rows with csv.DictReader, parse date with datetime.strptime and keep the rows for the chosen month.

  4. 4

    Summarise by category

    Use a dict or collections.defaultdict(float) to total each category; print a sorted table with percentages.

  5. 5

    Warn on budgets

    Store monthly limits per category in budget.json and print a warning when a category crosses 80% and 100%.

  6. 6

    Draw charts

    pip install matplotlib; plt.pie(totals.values(), labels=totals.keys(), autopct="%1.0f%%") and save with plt.savefig("march.png").

  7. 7

    Add a menu

    Wrap everything in a loop menu: 1 Add, 2 Summary, 3 Chart, 4 Budgets, 5 Exit.

๐Ÿš€ Make it stand out

  • +Rewrite the analysis with pandas
  • +Import a bank statement CSV
  • +Turn it into a Streamlit web app