Sub topic 4
Record transactions consistently
This chapter assumes you can read an online banking transaction list and do basic percentage arithmetic. Some Python or spreadsheet experience helps, but you can follow the ideas without it. Earlier chapters defined income, spending, and net cash flow, and compared tracking methods. This chapter covers the record layer: what one transaction looks like, and the rules that keep thousands of them comparable.
Every later step depends on this layer. Categories, reconciliation, monthly summaries, and trends are all calculations over your records. If two rows mean different things, the totals will be wrong in ways that are hard to trace.
What a transaction record is
A transaction record is one row that describes one movement of money in or out of one account. Keep the row small and the meaning of each field fixed.
| Field | Meaning | Example | Common mistake |
|---|---|---|---|
| date | The day the transaction happened or posted, in `YYYY-MM-DD` | 2026-10-02 | Mixing `10/02/2026` and `02/10/2026` formats |
| account | Which account or card it touched | Checking | Leaving it out, which makes reconciliation impossible |
| description | The payee or a short note | Rent | Pasting long bank codes that change each month |
| category | One label from your category set | Housing | Inventing a new label for each purchase |
| amount | A signed number | -1200.00 | Storing spending as positive in some rows and negative in others |
The next chapter covers how to design the category set. For now, treat category as a field that holds exactly one value per row.
You can add optional fields such as note, tag, or transfer_id. Add one only when you have a question it will answer. Each extra field is something you must fill in correctly every time.
Choose a sign convention and keep it
A sign convention is the rule for whether money in and money out are positive or negative. This tutorial uses the most common one for personal records:
- Income and other money coming in is positive.
- Spending and other money going out is negative.
With this rule, net cash flow for any set of rows is the plain sum of the amount column. You do not need to check each row's category to decide whether to add or subtract.
Banks do not all follow this convention, so you will often convert on import:
- Some checking exports use one signed column, which already matches.
- Some exports use separate Debit and Credit columns, both positive.
- Many credit card exports show purchases as positive numbers, because they represent growth in the amount you owe.
The last case is the most common source of sign errors. A card purchase of 86.40 shown as 86.40 must be stored as -86.40 in your records, because your cash position is worse off by that amount. Decide the rule once, write it down, and convert at the point of entry.
Convert a bank export
This script converts a Debit/Credit export into signed amounts. It uses Decimal rather than float, because binary floating-point cannot represent most cent values exactly and totals drift by fractions of a cent.
import csv
from decimal import Decimal
from io import StringIO
raw = """Date,Description,Debit,Credit
2026-10-01,Paycheck,,2500.00
2026-10-02,Rent,1200.00,
2026-10-17,Electric bill,92.10,
"""
def to_signed(row):
debit = Decimal(row["Debit"] or "0")
credit = Decimal(row["Credit"] or "0")
return credit - debit
for row in csv.DictReader(StringIO(raw)):
print(row["Date"], row["Description"], to_signed(row))The empty-string check (or "0") matters. Exports leave the unused column blank, and Decimal("") raises an error.
For a credit card export where purchases are positive, the conversion is simply -Decimal(row["Amount"]). Record that fact in a comment or a notes file, so you remember in a year why the sign flips.
Dates: pick one meaning
Banks give you up to two dates: the transaction date (when you paid) and the posted date (when the bank settled it). They can differ by several days, and sometimes by a month boundary. A purchase made on October 31 may post on November 2.
Pick one and use it for every account. Two practical rules:
- Use the posted date if you reconcile against statements. Statements are organized by posted date, so your monthly totals will match theirs.
- Use the transaction date if you care more about when you made the decision to spend, and accept small mismatches at month edges.
Whichever you choose, write dates as ISO 8601 (YYYY-MM-DD). It is unambiguous, and it sorts correctly as plain text.
Handle the awkward cases
Most rows are simple. The cases below are where records go wrong.
Transfers
Moving 500.00 from checking to savings is not income and not spending. If you record only one side, you will either invent 500.00 of income or lose 500.00 of spending. Record both sides, one negative in the source account and one positive in the destination, and give both the category Transfer. When you summarize, exclude Transfer rows. Paying a credit card bill is also a transfer. The spending was already recorded when you made the purchases.
Refunds and reimbursements
A refund is a positive amount. Record it in the same category as the original purchase, so the category's net total reflects what you actually spent. If you instead record it as Income, your income rises and your spending looks higher than it was.
Split transactions
One receipt can cover groceries and household supplies. If the categories matter to you, record two rows with the same date, account, and description, whose amounts add up to the receipt total. If you don't need that detail, use the main category and move on.
Pending, duplicate, and cash entries
- Pending transactions can change amount or disappear. Record them only after they post, or mark them and revisit.
- If you combine a manual log with a bank export, the same purchase can appear twice. Choose one source of truth per account.
- Cash has no bank record. Log it when you withdraw it, as a transfer to a "Cash" account, and log what you spend from it. If that is too much effort, record the withdrawal as spending in a category such as
Cash, and accept the loss of detail.
Foreign currency
Record the amount in your home currency, as charged to your account. If you want the original amount too, add a separate field. Do not mix currencies in one amount column.
Consistency in descriptions
You will group and search by description, so consistency helps. Use a short stable name for each payee: Grocery store or Electric bill, not POS DEBIT 4417 GROCERY #221 SPRINGFIELD. Keep the original bank text in a separate raw_description field if you want it for reference or for rules that auto-assign categories.
Validate rows before you trust them
Hand-entered and imported data both contain errors. A short check catches most of them at entry, when the correct answer is easy to find.
import csv
from collections import Counter
from datetime import date
from decimal import Decimal, InvalidOperation
from io import StringIO
data = """date,account,description,category,amount
2026-10-01,Checking,Paycheck,Income,2500.00
2026-10-02,Checking,Rent,Housing,-1200.00
2026-10-04,Credit card,Grocery store,Groceries,-86.40
2026-10-04,Credit card,Grocery store,Groceries,-86.40
2026-10-09,Checking,Coffee shop,Dining,4.75x
2026-13-01,Checking,Bad date,Dining,-5.00
2026-10-12,Checking,Paycheck bonus,Income,-300.00
"""
def problems_for(row):
found = []
try:
date.fromisoformat(row["date"])
except ValueError:
found.append("bad date")
try:
amount = Decimal(row["amount"])
except InvalidOperation:
found.append("bad amount")
else:
if row["category"] == "Income" and amount < 0:
found.append("income should be positive")
if not row["category"].strip():
found.append("missing category")
return found
rows = list(csv.DictReader(StringIO(data)))
seen = Counter()
for line_no, row in enumerate(rows, start=2):
key = (row["date"], row["account"], row["description"], row["amount"])
seen[key] += 1
issues = problems_for(row)
if seen[key] > 1:
issues.append("possible duplicate")
if issues:
print(f"line {line_no}: {', '.join(issues)}")Running it prints:
line 5: possible duplicate
line 6: bad amount
line 7: bad date
line 8: income should be positiveThe script reports a possible duplicate and does not delete it. Two identical coffees on one day can be real. The script's job is to point you to the row, and you decide.
The path of one transaction
The diagram shows the same steps whether you type entries by hand or import a file.
Common errors and how to spot them
| Symptom | Likely cause | Check |
|---|---|---|
| Net cash flow is far too high | A transfer recorded as income, or card payments missing from the transfer exclusion | Sum the `Transfer` rows. They should net to zero. |
| Spending looks doubled | Manual log and bank import both loaded | Look for repeated date, account, and amount |
| Month totals differ from the statement by a few purchases | Mixed transaction and posted dates | Compare rows near the month boundary |
| Totals differ by fractions of a cent | Floating-point arithmetic | Use `Decimal` or round amounts to cents on entry |
| One category shows a positive total | Refund larger than purchases, or a wrong sign | List the positive rows in that category |
The transfer check is useful beyond this chapter. If you have recorded both sides of every transfer correctly, the sum of all Transfer amounts is exactly zero. A nonzero result tells you a side is missing or has the wrong amount.
Exercises
Exercise
A credit card export lists a 42.00 purchase as 42.00 and a 15.00 refund as -15.00. Using this tutorial's sign convention, what amounts do you record, and what is the net effect on cash flow?
Show answer
Record the purchase as -42.00 and the refund as +15.00, because the card export uses the opposite sign. Flip both signs on import. The net effect is -27.00, and both rows go in the same category.
Exercise
You move 300.00 from checking to savings. Describe the two rows you record, and say whether they change net cash flow.
Show answer
One row in Checking with amount -300.00 and one row in Savings with amount +300.00, both categorized as Transfer. When transfers are excluded, net cash flow is unchanged. Their sum is zero either way.
Exercise
Why does the validation script flag a possible duplicate and not remove it automatically?
Show answer
Two identical purchases on the same day and account can both be real, such as two coffees at the same shop. Automatic removal would delete genuine spending. The script flags the row so you can compare it with the source.