add transaction CSV export and category suggestion features

This commit is contained in:
2026-10-08 16:48:03 -04:00
parent c23b8e8ef0
commit 0a1c5b2838
7 changed files with 810 additions and 18 deletions
+18
View File
@@ -126,6 +126,24 @@ print(f"Balance: ${balance / 1000:.2f}")
See `ynab_example.py` for a complete example that also saves all transactions to `ynab_transactions.json`.
### Export YNAB Transactions to CSV
Write transactions from the configured credit and debit accounts for the past 60 days:
```powershell
python .\main.py --record-transactions
```
Set a different lookback (1–240 days) and output path:
```powershell
python .\main.py --record-transactions=90 --transactions-csv .\exports\transactions.csv
```
The default output is `transactions.csv`. It contains only `payee`, `category`, `inflow`, and `outflow` columns. Split transactions are written as one row per subcategory, keeping the parent transaction's payee on each row. The misspelled `--record-trasactions` option is also accepted as an alias.
When importing bank transactions with `--ynab-import`, the importer uses `transactions.csv` and a reusable `category_memory.json` sidecar to suggest categories from similar payees, transaction direction, and amount. Confident suggestions are sent to YNAB; uncertain ones appear with a `?` in the preview and remain uncategorized. Each explicit `--record-transactions` export merges new patterns into the sidecar, so they remain available after older rows leave the CSV. Keep or sync both files between machines; the sidecar contains normalized payee/category/amount patterns but no transaction dates or IDs.
### ynab.yml Format
```yaml