Finance operations runs on spreadsheets because spreadsheets are flexible. That flexibility has a cost: every month starts with downloading the same exports, deleting the same columns, writing the same VLOOKUP, and hoping nobody overwrote a formula.
You do not need to replace Excel. You need to remove the repetitive parts that Excel is bad at: reproducible matching, strict parsing, and batch processing.
Here are five small Python scripts that earn their keep in a finance workflow. All of them use the standard library only. Each one is short enough to audit and can run on a locked-down laptop with no network access.
1. Reconcile payout exports against bank statements
The manual version: open the platform CSV and the bank CSV, sort both by order ID, eyeball rows, and copy the differences into a new tab.
The script: read both files, key transactions by order ID, compare gross amounts and fees, and write a Markdown + CSV report.
import csv
from decimal import Decimal
from pathlib import Path
def load(path):
with open(path, encoding="utf-8-sig", newline="") as f:
rows = list(csv.DictReader(f))
result = {}
for row in rows:
oid = (row.get("order_id") or row.get("reference") or "").strip()
amount = Decimal((row.get("gross") or row.get("amount") or "0")
.replace("$", "").replace(",", ""))
if oid:
result[oid] = amount
return result
left = load("stripe.csv")
right = load("bank.csv")
for oid in sorted(set(left) | set(right)):
if oid not in right:
print("missing in right", oid, left[oid])
elif oid not in left:
print("missing in left", oid, right[oid])
elif left[oid] != right[oid]:
print("amount mismatch", oid, left[oid] - right[oid])
This is deliberately minimal. A production version adds column detection, fee comparison, duplicate aggregation, and a written report. The important property is that the logic is in code: you can rerun it next month, review the diff, and commit it.
A better version of this script is the free csv-reconcile-cli linked at the end. It handles messy headers, decimal commas, duplicate order IDs, and report generation.
Use it when: you reconcile Stripe, PayPal, Gumroad, Shopify, Amazon, or a marketplace export against a bank or ledger.
2. Detect duplicate invoices before you pay twice
The manual version: sort by invoice number, scroll, and wonder whether two rows with the same vendor and amount are a duplicate or two legitimate installments.
The script: flag exact duplicate invoice IDs first, then suspicious vendor + amount + date combinations.
import csv
from collections import defaultdict
invoices = []
with open("invoices.csv", encoding="utf-8-sig", newline="") as f:
for row in csv.DictReader(f):
invoices.append(row)
by_id = defaultdict(list)
by_signature = defaultdict(list)
for row in invoices:
invoice_id = row["invoice_id"].strip().lower()
signature = (
row["vendor"].strip().lower(),
row["amount"].strip(),
row.get("invoice_date", "").strip(),
)
by_id[invoice_id].append(row)
by_signature[signature].append(row)
for invoice_id, rows in by_id.items():
if len(rows) > 1:
print(f"DUPLICATE ID: {invoice_id} ({len(rows)} rows)")
for signature, rows in by_signature.items():
if len(rows) > 1:
print(f"REVIEW: {len(rows)} invoices from {signature[0]} for {signature[1]}")
The second check produces false positives. That is fine. A review queue is still faster than reading every row. The output should tell a human what to inspect, not make an irreversible decision.
Use it when: accounts payable receives exports from multiple teams, entities, or forwarding inboxes.
3. Normalize mixed currencies with an explicit rate table
The manual version: add a rate column, copy today's rate from a website into twelve rows, multiply, and forget which rate snapshot was used at month-end.
The script: keep rates in a JSON file and convert every row to a reporting currency.
import csv
import json
from decimal import Decimal
with open("rates.json", encoding="utf-8") as f:
rates = {k: Decimal(str(v)) for k, v in json.load(f)["rates"].items()}
base = "USD"
def convert(amount, currency):
if currency == base:
return amount
return amount * rates[currency] / rates[base]
with open("orders.csv", encoding="utf-8-sig", newline="") as src, \
open("orders_usd.csv", "w", encoding="utf-8", newline="") as dst:
reader = csv.DictReader(src)
writer = csv.DictWriter(dst, fieldnames=reader.fieldnames + ["amount_base"])
writer.writeheader()
for row in reader:
amount = Decimal(row["amount"])
currency = row["currency"].upper()
row["amount_base"] = f"{convert(amount, currency):.2f}"
writer.writerow(row)
Rates in this example are expressed as USD per one unit of currency. That convention must be written down. A rate table without a direction is a bug waiting to happen.
Do not fetch a live rate inside a close script unless you also store the timestamp and value used. Reconciliation needs reproducibility more than it needs real-time data.
Use it when: your orders, payouts, and bank account use different currencies, or when one entity reports in a currency different from the source exports.
4. Build an accounts receivable aging report
The manual version: add an =TODAY()-due_date column, bucket the results, pivot, and rebuild it next week.
The script: calculate age buckets from a snapshot date so the output is reproducible.
import csv
from datetime import date
from decimal import Decimal
as_of = date(2026, 11, 30)
buckets = {"current": Decimal("0"), "1-30": Decimal("0"),
"31-60": Decimal("0"), "61-90": Decimal("0"), "90+": Decimal("0")}
with open("open_invoices.csv", encoding="utf-8-sig", newline="") as f:
for row in csv.DictReader(f):
due = date.fromisoformat(row["due_date"])
days = (as_of - due).days
amount = Decimal(row["amount"])
if days <= 0:
bucket = "current"
elif days <= 30:
bucket = "1-30"
elif days <= 60:
bucket = "31-60"
elif days <= 90:
bucket = "61-90"
else:
bucket = "90+"
buckets[bucket] += amount
for bucket, total in buckets.items():
print(f"{bucket:>8}: {total:,.2f}")
The snapshot date is a parameter, not date.today(). That one choice makes tests possible and lets you reproduce last month's report exactly.
Use it when: you need a weekly AR review without opening an ERP report builder.
5. Generate a monthly close manifest
The manual version: a checklist in a document, with no proof that the files used were the files you think you used.
The script: hash every source file, record row counts, and write a small manifest.
import csv
import hashlib
from datetime import datetime, timezone
from pathlib import Path
sources = sorted(Path("exports").glob("*.csv"))
lines = [f"# Close manifest — {datetime.now(timezone.utc):%Y-%m-%d %H:%M UTC}", ""]
for path in sources:
digest = hashlib.sha256(path.read_bytes()).hexdigest()[:16]
with path.open(encoding="utf-8-sig", newline="") as f:
rows = sum(1 for _ in csv.reader(f)) - 1
lines.append(f"- `{path.name}` — {rows} data rows — sha256:{digest}")
Path("manifest.md").write_text("\n".join(lines), encoding="utf-8")
This does not reconcile anything by itself. It answers a different, equally important question: which files produced this month's numbers? When someone asks why the close changed, the manifest narrows the investigation immediately.
Use it when: multiple people or systems contribute files to a close, or when auditability matters more than speed.
The common pattern
All five scripts share the same shape:
- Read a file with an explicit encoding.
- Parse values into strict types, especially money.
- Apply a deterministic rule.
- Write a reviewable artifact.
- Keep the input paths and thresholds visible.
That is the real upgrade over manual spreadsheet work. It is not that Python is faster at arithmetic. It is that the procedure is written down, rerunnable, and reviewable.
Make the scripts boring
A finance script should be boring in the best sense:
- no hidden network calls
- no silent coercion of bad rows to zero
- no dependence on row order
- no “current date” without a parameter
- warnings when a column or currency is missing
- output that names the source files
Boring is auditable. Auditable is what finance actually needs.
A note on scope
You can build each of these in an afternoon. Maintaining five unrelated scripts is the harder part. That is why I consolidated the reconciliation workflow into a single zero-dependency CLI:
- The free open-source edition does order/amount/fee matching and writes Markdown + CSV reports.
The Pro Automation Kit adds multi-currency FX, Stripe/PayPal/Gumroad/Shopify/Amazon presets, interactive HTML reports, and batch folder scanning.
Free GitHub repo: https://github.com/lcwhgzsyzc-boop/csv-reconcile-cli
Pro kit ($9): https://3275766967876.gumroad.com/l/hngxh
Start with the script that removes the most repetitive hour from your month. Then make it runnable by someone else. That is how spreadsheet work becomes operations.
Top comments (0)