Skip to content
IT Vizag
← Files, Modules & Packages

▶ Sign up free for the video, slides & prompts

The lesson below is open to all. Enter your email once to unlock every video, slide deck, prompt and code example on this device.

Checking…

Mini project: expense tracker

Lesson 10 of 10 · 3 min read

Save expenses to a CSV and print monthly totals.

🎬 Video version coming soon — read it now

Let's build a small app you might actually use daily: an expense tracker that saves to a CSV file, so your data survives after the program closes.

Features

  1. Add an expense: date, category, amount and note
  2. List all expenses
  3. Show totals per category for any month
  4. Data stored in expenses.csv, so you can also open it in Excel

The code

🔒 Code example: sign up free (above) to unlock it.

How it fits together

  • pathlib checks whether the file exists; csv reads and writes it
  • datetime stamps each expense; ISO dates (2026-12-06) sort correctly and make month filtering a simple startswith
  • Mode "a" appends, and the header is written only once
  • The same dictionary-of-functions menu idea from the unit converter

Run it on your laptop (python expenses.py) so the CSV stays between runs, then open expenses.csv in Excel.

Challenges

  1. Add a monthly budget per category and warn when you go over.
  2. Let the user enter a date instead of always using today.
  3. Export the monthly report to a JSON file.
  4. Add a "delete last expense" option. Hint: load, remove the last item, rewrite the whole file with "w".

What you learned in this course

  • Text, CSV and JSON files, and the with statement
  • Modules, import and the standard library
  • pip, requirements.txt and virtual environments
  • Running Python on your own laptop, and automating tasks safely with AI

Next course: Objects & Classes. You'll learn to model real things, such as bank accounts, students and products, as objects.

In one line

You built an app that saves data between runs, using csv, pathlib, datetime and clean functions.

Saved on this device. Sign in to keep progress everywhere.

Share with a friend