Guide · 30

Expense categorizer

Sorts a bank statement into categories by keyword, totals by category and month, and lists what is unclassified.

In one line

node scripts/30-expense-categorizer.mjs releve.csv --rules regles.json

What it's for

A 300-line bank statement tells you nothing until it is sorted. This script puts each line into a category using keywords you define, then totals by category and by month, and shows what remains unclassified so you can complete your rules.

Before you start

  • A CSV export from your bank with date, label and amount (negative for an expense).
  • A JSON rules file: { "Transport": ["uber", "fuel"], "Software": ["github", "notion"] }.

Step by step

  1. Run:
    node scripts/30-expense-categorizer.mjs samples/depenses.csv --rules samples/regles.json --out sorted.csv
    
  2. Look at the "Non classé" lines and add keywords to the rules file.
  3. Run again until the unclassified part is marginal.

Reading the output

Totals per category (biggest spending first), then per month. Keywords ignore case and accents. Rule order matters: the first category with a keyword found in the label wins.

Automating it

Each month, drop in the new export and re-run: your rules grow richer over time. The --out file reopens in a spreadsheet.

Pitfalls

  • A keyword that is too short ("bar") catches far too much: prefer distinctive fragments.
  • Your statements are sensitive data: keep them out of public repositories.

This guide goes with a free script (MIT license). Try it on a copy of your data first.