Problem
Financial data from GnuCash SQLite databases often needs to be presented in a professional, readable format with proper currency symbols, thousands separators, and column alignment. Currently, raw SQL output is difficult to read and share.
Proposed Solution
Add a new package packages/format-financial/ with a Python script that formats financial data tables with:
Key Features
- Currency formatting: Automatic
$ symbols and thousands separators ($1,234.56)
- Perfect column alignment: Dynamic width calculation for clean tables
- Dual output modes: Both plain text (terminal-friendly) and markdown table formats
- Decimal precision: Uses Python's
Decimal class to avoid floating-point errors
- Testable design: I/O separated from formatting logic with comprehensive doctests
Usage Examples
# Plain text output (also valid markdown)
python3 format_financial.py database.sqlite view_name
# Pure markdown output
python3 format_financial.py database.sqlite view_name --markdown
Sample Output
| as_of_date | assets | liabilities | net_worth | retained_earnings | equity | eq |
| ---------: | ----------: | ----------: | ----------: | ----------------: | ----------: | ----: |
| 2024-12-31 | $796,380.82 | $0.00 | $796,380.82 | $25,222.54 | $771,158.28 | $0.00 |
| 2025-06-30 | $811,111.21 | $0.00 | $811,111.21 | $36,153.82 | $774,957.39 | $0.00 |
Technical Implementation
- Object capability discipline: SQLite connections and stdout injected for testability
- doctests: any code that doesn't work the first time gets fixed with red/green TDD using doctest
Benefits
- Professional financial reports suitable for sharing
- Works with any SQLite view/table containing financial data
- Eliminates manual formatting of GnuCash query results
- Reusable across different finquick workflows
- Well-tested and maintainable code
Problem
Financial data from GnuCash SQLite databases often needs to be presented in a professional, readable format with proper currency symbols, thousands separators, and column alignment. Currently, raw SQL output is difficult to read and share.
Proposed Solution
Add a new package
packages/format-financial/with a Python script that formats financial data tables with:Key Features
$symbols and thousands separators ($1,234.56)Decimalclass to avoid floating-point errorsUsage Examples
Sample Output
Technical Implementation
Benefits