Menu

Post image 1
Post image 2
1 / 2
0

Stop Manually Categorizing Expenses: Automate It with Python

DEV Community·Brad·20 days ago
#rVXj7Gnf
Reading 0:00
15s threshold

Every month I used to spend 2-3 hours going through bank statements and categorizing expenses for tax purposes. "Is that $34.99 charge from AWS or personal? Let me scroll back and check..." This script ended that. It reads your bank CSV export and auto-categorizes everything. How It Works Most banks let you export transactions as CSV. The format varies, but they all have: date, description, amount. My script reads that CSV and applies pattern matching to categorize each transaction. import csv import re from collections import defaultdict from datetime import datetime # Define your category rules (regex patterns → category) CATEGORIES = { " Software & Subscriptions " : [ r " AWS|AMAZON WEB|GOOGLE CLOUD|DIGITALOCEAN|HEROKU " , r " GITHUB|GITLAB|NOTION|FIGMA|ADOBE|CANVA " , r " STRIPE|GUMROAD|SHOPIFY " , r " ZOOM|SLACK|DISCORD|LOOM " , ], " Advertising " : [ r " GOOGLE ADS|FACEBOOK ADS|META PLATFORMS|TWITTER ADS " , r " LINKEDIN|REDDIT ADS " , ], " Office & Equipment " : [ r "…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More