Skip to content

How to Categorize Transactions From CSV Files

Categorize transactions from CSV files with a short category list and merchant rules, and handle split purchases and messy merchant names.

By Published Updated

To categorize transactions from a CSV file without doing every row by hand, pick a short list of categories, then write merchant rules that match text in the description column and assign a category. Rules handle the merchants you see every month. You tag the leftovers by hand, and each hand tag can become a new rule.

This post covers how many categories to start with, how to write rules that fire on the right rows, why one store appears under several names, what to do with a purchase that belongs in two categories, and how to keep your fixes from being lost when next month's file arrives.

Picking a Category List for CSV Transactions

A good category list for CSV transactions has between eight and fifteen entries, each one a place where you could actually change your behavior. Fewer than eight hides useful detail, such as dining inside a broad food line. More than fifteen means you spend your time choosing between near-identical labels instead of reading the totals.

A practical starting list for a household looks like this. Housing covers rent or mortgage and insurance on the home. Utilities covers power, water, gas, internet and phone. Groceries covers food you cook at home. Dining covers restaurants, cafes and takeout. Transport covers fuel, transit, parking and rideshare. Health covers pharmacy, doctor and dental bills. Subscriptions covers recurring digital services. Shopping covers clothes, household goods and electronics. Personal covers haircuts, gifts and hobbies. Add Income and Transfer as two more labels that never count as spending.

Two tests help when you are unsure whether a category earns its place. First, would you set a budget for it? If yes, keep it. Second, does it ever hold more than a few rows a month? If it holds one row every three months, fold it into a neighbor.

Resist renaming categories often. Every rename breaks comparisons with earlier months unless you go back and relabel the old rows too. Settle the list in the first month, then change it only when a category is clearly too broad or too empty.

Merchant Keyword Rules for CSV Categorization

A merchant keyword rule says that any row whose description contains a given piece of text gets a given category. Rules are checked in order, and the first match wins. A dozen well-chosen rules usually cover most rows in a household file, because the same grocery store, fuel station and utility appear every month.

The table below is an example set of rules with made-up merchant names. The pattern column is the text to look for, matched without regard to capital letters.

Order Pattern in description Category Example row Result
1 TRANSFER TO Transfer TRANSFER TO SAVINGS 4471, $250.00 Transfer
2 PAYROLL Income PAYROLL DEP BRIGHTLINE CO, $2,310.00 Income
3 AUTOPAY Transfer CARD AUTOPAY THANK YOU, $842.16 Transfer
4 FRESHWAY Groceries FRESHWAY MKT #0214 OAKDALE, $76.42 Groceries
5 QUICKFUEL Transport QUICKFUEL 0331 OAKDALE, $51.20 Transport
6 METRO TRANSIT Transport METRO TRANSIT FARE 09/14, $2.75 Transport
7 NORTHSIDE POWER Utilities NORTHSIDE POWER CO WEB PMT, $124.60 Utilities
8 STREAMBOX Subscriptions STREAMBOX*MONTHLY 800-555-0142, $15.99 Subscriptions
9 CAFE Dining BEAN AND LEAF CAFE, $8.40 Dining
10 PHARM Health CORNER PHARMACY #22, $18.75 Health
11 SQ * Review SQ *RIVERSIDE MARKET STAND, $23.00 Review

Order matters for three reasons in this table. Transfers and income come first, so a description that happens to contain a store name, such as a payment to a store's credit card, is never counted as spending. Specific patterns come before broad ones. "CAFE" is broad and would also match a grocery store called "Cafe Market," so any rule for that store must sit above it. The last rule catches payment processor prefixes, such as "SQ *", and sends them to a Review label instead of guessing. A processor name tells you how the payment was taken, not what was bought.

Writing patterns that hold up

Keep each pattern to the part of the description that never changes. Store numbers, city names, dates and phone numbers vary from row to row, so "FRESHWAY" works and "FRESHWAY MKT #0214 OAKDALE" fails the first time you shop at a different branch. Avoid patterns shorter than four or five letters, because short text matches inside unrelated words. "GAS" matches "VEGAS" and "GASTROPUB."

In a spreadsheet, the simplest version is a two-column rules table and a lookup formula that searches each description for each pattern and returns the first matching category. Rows with no match come back empty, which is what you want, because an empty cell is a row to look at.

Why Does One Merchant Show Up Under Different CSV Names?

One merchant shows up under different CSV names because the description comes from the card network and the merchant's payment setup, not from the brand you know. The same store can bill under a branch number, a parent company, an online store name or a payment processor, and each of these lands as different text in your file.

Here is how one example grocery chain might appear across a single month. "FRESHWAY MKT #0214 OAKDALE" for the usual branch. "FRESHWAY MARKET 0377" for a branch near work. "FRESHWAY.COM ORDER" for a delivery order. "FWM FUEL 0214" for the chain's fuel station. The first three share the word FRESHWAY and one rule catches them. The fourth shares nothing and needs its own rule, which may belong under Transport rather than Groceries.

Grouping variants takes two passes. First, sort the uncategorized rows by description, so near-identical names sit next to each other. Second, find the shortest stable text the variants share and use it as the pattern. When variants share nothing, write one rule per variant and keep them together in the rules table with a note, so you remember they are the same merchant.

Some descriptions are hard to read at all. A string like "PP*8842MERCH" or a parent company name you have never heard of needs a quick check against your receipts or email before you write a rule. Turning those rows into a clean list of expenses is a task of its own, and the guide to extracting expenses from a bank statement covers reading unfamiliar lines.

Split Purchases That Fit Two CSV Categories

A split purchase is one CSV row that pays for things in two categories, such as a store trip that was part groceries and part household goods. Your bank file has one amount for the whole trip. To categorize it properly, copy the row, divide the amount between the two copies, and give each copy its own category.

Take an example. A big-box store row reads "VALUMART #1182, $143.20." The receipt shows $88.70 of food and $54.50 of cleaning supplies and a kettle. Replace the single row with two rows, both dated the same day with the same description. Give one $88.70 and Groceries, the other $54.50 and Shopping. Add a note column that says "split from $143.20" so the original total is easy to rebuild.

Splitting every mixed trip takes time, and it is only worth it when the split changes a decision. If you shop at a big-box store twice a month and the non-food part is always small, give the whole row to Groceries and accept a slightly high grocery number. If the non-food part is often large, or if one part is a business expense you need to separate, split it.

A middle path works well for regular mixed trips. Use a fixed share, such as 70% Groceries and 30% Shopping, for one merchant, and review it every few months against a handful of receipts. It is not exact, but it is consistent, and consistency is what makes month-to-month comparisons hold.

Keep the split rows' total equal to the original amount. A split that loses a cent breaks any check against the bank's balance.

How Many CSV Rows Should You Categorize by Hand?

Hand-categorize the CSV rows that no rule matches, but write a new rule only for a merchant you expect to see again. A one-off purchase at a shop you will never visit twice deserves a hand tag and nothing more. A merchant that appears every month deserves a rule, even if it took only a second to tag by hand.

A rough test is to look at what is left after the rules run. If the leftovers are mostly one-off purchases, your rules are doing their job. If the same few merchants appear in the leftovers month after month, those need rules.

There is a point where more rules cost more than they save. Each rule is something to maintain, and a long list starts to conflict with itself, with two rules matching the same row and the wrong one winning. Watch for the moment when adding a rule means first checking which of forty others might already match. That is usually the sign to stop adding and start pruning.

An example month makes the trade clear. Suppose a checking export has 74 rows. Twelve rules catch 61 of them. Of the 13 left, nine are one-offs, such as a hardware store visit or a concert ticket, and four are a new lunch spot near a new office. Tag all 13 by hand, and add one rule for the lunch spot. Next month the leftovers drop to about nine.

Rules have limits that no amount of tuning fixes. They read text, so they cannot tell that a pharmacy row was a birthday card rather than medicine, or that one restaurant charge was a work lunch. Software that reads the whole description and the surrounding rows does better on these, and the post on what an AI finance agent does explains where that kind of tool helps and where it still needs you.

Keeping CSV Category Corrections Consistent Over Time

CSV category corrections stay consistent over time when every fix becomes a rule or a saved exception, rather than an edit in one month's file. If you change a category in September's sheet and nothing records it, October's import makes the same mistake again, and the two months disagree about where that merchant belongs.

Keep the rules in their own tab or file, apart from any month's transactions. When you correct a row, ask whether the fix applies to the merchant or only to that one row. A merchant fix goes into the rules table. A one-row fix, such as a single work lunch, goes into an exceptions list keyed by date, amount and description, so it can be reapplied if you re-import the month.

Date your rule changes. A short log that says "Oct 2026, moved CORNER PHARMACY from Shopping to Health" explains why a category total jumped and lets you relabel older months if you want them to match.

Recheck old months after a big change. Moving a merchant from one category to another changes every earlier month's totals too, if you reapply the rules. Decide whether you want history rewritten to the new list or frozen as it was, and stay with that choice.

A tool that imports CSV files can carry corrections for you. MoneyOS categorizes each row on import, and when you correct a category it remembers the correction. The MoneyOS FAQ covers how its categories and corrections work. If you would rather keep the whole routine in a spreadsheet, the post on running a bank CSV expense tracker month after month sets out the monthly steps and a master file layout.

Whatever holds your rules, review them once a quarter. Delete rules for merchants you no longer use, merge rules that point to the same category, and check that the order still puts specific patterns above broad ones.

Also available as Markdown.