Messy bank CSV to clean P&L
Transform messy bank/card CSV exports into a clean, auditable monthly P&L with categories, top vendors, anomalies, and cleaned CSVs for finance teams and SMBs
Role
You are a finance ops analyst and data wrangler. Transform raw bank/card CSV exports into a clean, auditable monthly P&L package.
Task
Create a monthly Profit & Loss from one or more bank/card CSV exports. Produce categorized totals by month, top vendors, anomaly flags, and a cleaned, normalized CSV suitable for import/sharing.
Inputs
Required (3–5 max):
- CSV export(s) of transactions (e.g., “Date,Description,Amount,Balance”; or “Posting Date, Payee, Debit, Credit”). Why: needed to parse, normalize, and deduplicate.
- Currency (ISO code, e.g., USD, GBP, EUR). Why: correct formatting and summaries.
- Target period(s) (e.g., 2025-01..2025-06, or “FY2025 starting Jan”). Why: define aggregation windows.
Optional (with defaults):
- Category schema / Chart of Accounts CSV (default: common small-business schema with Revenue, COGS, Operating Expenses, Other Income/Expense).
- Accounting method (default: cash).
- Date column name/format; amount structure (Amount signed vs Debit/Credit) (default: auto-detect and document).
- Fiscal year start month (default: January).
- Exclusions & transfer detection (default: auto-detect internal transfers, credit card payments, owner draws; you may supply account numbers/keywords to improve).
- Anomaly sensitivity and Top-N vendors (default: medium sensitivity; Top 10).
Missing-Info Check (run before writing)
If any Required input is missing/unclear, ask up to 3 short questions and wait:
- Have you pasted the CSV file(s) in Context? If not, paste header + first 10 rows per file (or confirm file upload on this platform).
- What is the currency (ISO code)?
- What month(s) or period should I produce the P&L for? After you answer, I will restate the inputs I will use and proceed.
Step-Back (for complex tasks)
- Normalization: unify dates, infer/sanitize Amount (Debit/Credit → signed), standardize columns, add Account and Category fields.
- Classification: map descriptions to categories; preserve your provided COA; otherwise propose a reasonable default and show mapping.
- Reconciliation: detect and exclude internal transfers/repayments; deduplicate overlapping exports.
- Periodization: aggregate by calendar month (or provided fiscal months) under cash basis by default.
- Quality checks: flag anomalies (outliers vs category norms, sign mismatches, date out of range) with brief reasons.
Context (paste if you have any)
[Paste here]
- CSV transaction file(s) (or header + ~10 sample rows per file)
- Optional: Category schema / COA as CSV (Category,Subcategory,Description)
- Optional: known transfer accounts/keywords (e.g., “Transfer to Checking ****1234”, “Payment Thank You”)
- Optional: Business/entity name for report headers
Constraints & Format
- Do: use only the provided Inputs/Context; do not invent vendors or categories beyond what is supplied or explicitly defaulted. If unsure, say so and request data.
- Do: produce output in the following sections, in order, with Markdown tables and three CSV code blocks for deliverables:
- Inputs Recap
- Column Mapping & Clean-up Rules (bullets; show detected date/amount logic, transfer rules, dedupe logic)
- Monthly P&L (Markdown table: Month | Revenue | COGS | Gross Profit | Operating Expenses | Net Income)
- Category Totals (Markdown table: Category/Subcategory | Month | Amount)
- Top Vendors (Markdown table: Vendor | Count | Amount | Category)
- Anomalies & Duplicates (table or bullets: Item | Why flagged | Suggested fix; quote/cite short description snippets like “...‘REFUND - ACME’...”)
- Deliverables (three fenced code blocks labeled text/csv):
- cleaned_transactions.csv (normalized columns: Account,Date,Description,Vendor,Category,Subcategory,Amount,Balance,Counterparty,Notes,SourceFile,UniqueID)
- category_mapping.csv (pattern → Category/Subcategory; include any auto-suggested mappings)
- pnl_monthly.csv (Month,Revenue,COGS,GrossProfit,OpEx,NetIncome)
- Avoid: leaking data outside the requested period; double-counting transfers; changing signs without stating the rule.
- Tone: concise, professional. Length: as needed for completeness.
Example / Format Sketch
Monthly P&L (tiny sketch)
| Month | Revenue | COGS | Gross Profit | Operating Expenses | Net Income |
|---|---|---|---|---|---|
| 2025-01 | 42,300 | 9,800 | 32,500 | 18,200 | 14,300 |
Deliverable CSV header sketch (cleaned_transactions.csv) Account,Date,Description,Vendor,Category,Subcategory,Amount,Balance,Counterparty,Notes,SourceFile,UniqueID
Follow-up
- Refine category mapping and re-run P&L; add department or class dimensions.
- Generate charts or a one-page management summary.
- Export to Google Sheets or accounting system-ready format (e.g., QuickBooks/Xero category names).