Local Budget
Analyze bank/credit card CSV exports, categorize transactions, compare against budgets, and generate clean markdown reports for Obsidian.
Workflow Overview
- 1. Parse — run
parse_csv.py to normalize raw CSVs into a unified JSON format - Categorize — run
categorize.py to get LLM-ready JSON with suggested categories; review/adjust - Report — run
report.py to generate a markdown spending report
All scripts live in scripts/. Budget config and sample data in assets/. See references/csv-formats.md for supported formats and references/categories.md for category customization.
Step 1: Parse CSV
CODEBLOCK0
- - Auto-detects format if
--format is omitted (checks header columns) - Outputs a unified JSON array of transaction objects
- Each transaction: INLINECODE8
- Debits are positive amounts; credits (refunds/income) are negative
- Handles multiple date formats:
MM/DD/YYYY, YYYY-MM-DD, INLINECODE11 - Skips rows with missing date or amount; logs warnings to stderr
If the user's bank isn't auto-detected, check references/csv-formats.md for column mappings and use --format generic with the appropriate flag, or add a new format.
Step 2: Categorize Transactions
CODEBLOCK1
- - Outputs a JSON file with each transaction tagged with a suggested
category based on description keyword matching - The LLM (you) should review the output and adjust categories before generating the report
- Default categories: Housing, Food & Dining, Transportation, Utilities, Entertainment, Shopping, Health, Subscriptions, Income, Other
- To adjust: edit the JSON directly, or tell the user which transactions look miscategorized and confirm corrections
- See
references/categories.md for the keyword-matching logic and how to customize
LLM review step: After running categorize.py, scan the output for anything in "Other" or with low-confidence keywords. Ask the user to confirm or correct those entries before proceeding.
Step 3: Generate Report
CODEBLOCK2
- - Generates a markdown report with:
- Monthly summary (total in/out)
- Spending by category with budget vs. actual comparison
- Top 10 merchants by spend
- Month-over-month trend if multiple months present in the data
- Overage alerts for categories that exceed budget
- - If
--budget is omitted, report shows actuals only (no budget comparison) - Output is Obsidian-compatible markdown with frontmatter
Budget Config
Budget is defined in a JSON file. See assets/sample-budget.json for a realistic example.
CODEBLOCK3
Common Tasks
"Analyze my Chase export"
→ parse_csv.py chase_export.csv --format chase --output tx.json
→ categorize.py tx.json --output cat.json
→ Review categories, then INLINECODE20
"Show me my spending for March"
→ Parse and categorize the CSV, then filter by month in report.py (it auto-groups by month)
"I went over budget on dining"
→ Run the full pipeline; report.py flags overage categories with ⚠️
"Add a new bank format"
→ See references/csv-formats.md for the column mapping spec
"Customize categories"
→ See references/categories.md to edit keyword lists or add new categories
File Locations
Store CSVs and JSON outputs wherever the user prefers. Default working directory is wherever the command is run. Suggest keeping exports in a dedicated folder like ~/finances/exports/.
Reports can be saved directly to the Obsidian vault:
CODEBLOCK4
本地预算
分析银行/信用卡CSV导出文件,对交易进行分类,与预算进行比较,并为Obsidian生成简洁的Markdown报告。
工作流程概览
- 1. 解析 — 运行 parse_csv.py 将原始CSV文件标准化为统一JSON格式
- 分类 — 运行 categorize.py 获取带有建议分类的、可供LLM处理的JSON文件;审查/调整
- 报告 — 运行 report.py 生成Markdown格式的支出报告
所有脚本位于 scripts/ 目录。预算配置和示例数据位于 assets/ 目录。支持的格式请参见 references/csv-formats.md,分类自定义请参见 references/categories.md。
第一步:解析CSV
bash
python3 scripts/parse_csv.py [--format chase|boa|generic] [--output transactions.json]
- - 如果省略 --format 参数,将自动检测格式(检查表头列)
- 输出交易对象的统一JSON数组
- 每个交易:{ date: YYYY-MM-DD, description: str, amount: float, type: debit|credit, original_category: str|null }
- 支出为正数;收入(退款/收入)为负数
- 支持多种日期格式:MM/DD/YYYY、YYYY-MM-DD、MM/DD/YY
- 跳过缺少日期或金额的行,并将警告记录到stderr
如果用户的银行无法自动检测,请查看 references/csv-formats.md 了解列映射,并使用适当的标志配合 --format generic,或添加新格式。
第二步:分类交易
bash
python3 scripts/categorize.py transactions.json [--budget assets/sample-budget.json] [--output categorized.json]
- - 输出一个JSON文件,其中每笔交易根据描述关键词匹配被标记为建议的 category
- LLM(你)应在生成报告前审查输出并调整分类
- 默认分类:住房、餐饮、交通、公用事业、娱乐、购物、健康、订阅、收入、其他
- 调整方式:直接编辑JSON,或告知用户哪些交易看起来分类错误并确认更正
- 关键词匹配逻辑及自定义方法请参见 references/categories.md
LLM审查步骤: 运行categorize.py后,扫描输出中标记为其他或关键词置信度低的条目。在继续之前,请用户确认或更正这些条目。
第三步:生成报告
bash
python3 scripts/report.py categorized.json [--budget assets/sample-budget.json] [--output report.md]
- 月度摘要(总流入/流出)
- 按分类的支出与预算对比
- 消费最高的前10个商户
- 如果数据包含多个月份,显示环比趋势
- 超出预算的分类的预警提示
- - 如果省略 --budget,报告仅显示实际数据(无预算对比)
- 输出为兼容Obsidian的Markdown格式,包含前置元数据
预算配置
预算在JSON文件中定义。请参见 assets/sample-budget.json 获取实际示例。
json
{
monthly_budgets: {
Housing: 1800,
Food & Dining: 600
}
}
常见任务
分析我的Chase导出文件
→ parsecsv.py chaseexport.csv --format chase --output tx.json
→ categorize.py tx.json --output cat.json
→ 审查分类,然后 report.py cat.json --budget assets/sample-budget.json
显示我三月份的支出
→ 解析并分类CSV文件,然后在 report.py 中按月筛选(它会自动按月分组)
我在餐饮上超预算了
→ 运行完整流程;report.py 会用 ⚠️ 标记超预算的分类
添加新的银行格式
→ 参见 references/csv-formats.md 了解列映射规范
自定义分类
→ 参见 references/categories.md 编辑关键词列表或添加新分类
文件位置
CSV和JSON输出可存放在用户偏好的任何位置。默认工作目录为命令运行所在的目录。建议将导出文件保存在专用文件夹中,如 ~/finances/exports/。
报告可以直接保存到Obsidian库中:
bash
python3 scripts/report.py categorized.json --output ~/path/to/vault/finance/2024-03-budget.md