Skip to content

Project · Python Programming

Project: a UPI expense analyser

Projectintermediate· about 4 hours· 7 steps

The brief

Read a month's bank statement from CSV, skip the broken row, sort every UPI payment into a category with regular expressions, check the spending against a JSON budget and produce a month summary.

Why it matters

Money-management apps, bank dashboards and chartered accountants' tools all start with a messy statement export like this one. Reading CSV safely, cleaning amounts, tagging transactions and comparing with a budget is everyday work for a Python data or back-office developer.

Skills you practise

  • functions
  • try/except
  • csv with io.StringIO
  • datetime.date
  • re.search
  • collections.defaultdict
  • json.loads
  • sorting with key

What you will have at the end

expenses.py: a tested statement analyser that reads a CSV export, tags each payment, flags over-budget categories and prints a JSON-ready month summary.

How it is marked (rubric, 100 points)
Correct resultsAll seven checks pass, including the broken row, the empty statement and the word-boundary rule.40
Robust with messy dataBad amounts are skipped with a narrow try/except; nothing crashes on an empty statement or an unknown category.20
Good use of the standard librarycsv, io, datetime, re, collections and json each used where they fit, instead of hand-written parsing.20
Clean functionsSmall functions with docstrings that reuse each other; rules kept as data, not as a long if/elif chain.20

0/7 steps done

Step 1 of 7

Read an amount safely

parse_amount(text) returns the amount as a float, or None when the text is not a number (like "n/a" or "").

float("-349.00") gives -349.0, but float("n/a") raises a ValueError and would stop the whole program. Wrap the conversion in try/except and return None when it fails. Catch only the errors you expect (ValueError, and TypeError for None), never a bare except.

Run shows what your code prints. Check runs the step's tests. Ctrl+Enter checks too.