A Python tool for parsing grocery receipt data and generating spending analytics.
This project transforms unstructured receipt data into actionable spending insights:
- Parse receipt transactions into structured data
- Categorize items automatically
- Generate multi-dimensional spending analysis
- Export to Excel with formatted tables and dashboards
- Extracts transaction metadata (date, time, store, totals)
- Parses line items with prices and tax flags
- Computes derivative metrics:
- Day of week, time of day patterns
- Pre-discount totals and savings percentages
- Effective tax rates
- Self-checkout detection
Automatically categorizes grocery items into:
- Dairy, Meat/Protein, Fruit, Vegetables
- Cereal, Snacks, Beverages, Bakery
- Frozen, Candy/Sweets, Eggs
- And more...
| Analysis | Description |
|---|---|
| By Store | Spending and visits per location |
| By Month | Monthly spending trends |
| By Day of Week | Which days you shop most |
| By Time of Day | Morning/Afternoon/Evening patterns |
| By Category | What you spend the most on |
| Top Items | Most frequently purchased items |
| Savings Tracking | Discount utilization |
Creates a formatted workbook with:
- Transactions sheet - All receipt summaries with formatting
- Items sheet - Line-item detail with categories
- Dashboard - Summary metrics and instructions
Receipt transactions follow this structure:
{
'receipt_id': 'XXXX XXX XXX XXX',
'date': '01/15/2026',
'time': '14:30',
'store_name': 'Store Name',
'store_address': '123 Main St',
'city': 'City',
'state': 'FL',
'zip': '12345',
'subtotal': 45.00,
'sales_tax': 2.50,
'grand_total': 47.50,
'savings': 10.00,
'payment_method': 'Credit Card',
'items': [
('ITEM NAME', 4.99, 'F'), # F = Food stamp eligible
('TAXABLE ITEM', 3.99, 'TF'), # T = Taxable, F = Food
('Promotion', -2.00, 'F'), # Negative = discount
]
}openpyxl
pip install openpyxl- Copy
config_example.pytoconfig.py - Update paths to match your data directory
# Parse receipts and generate CSVs
python parse_receipts.py
# Create Excel workbook
python create_excel.py| File | Description |
|---|---|
transactions.csv |
Summary of each receipt |
items.csv |
Line items with categories |
summary.csv |
Aggregated statistics |
spending_database.xlsx |
Formatted Excel workbook |
receipt-parser/
├── README.md
├── config_example.py # Template configuration
├── parse_receipts.py # Receipt parsing and analytics
├── create_excel.py # Excel workbook generator
├── requirements.txt # Dependencies
└── .gitignore
- Python 3.x
- openpyxl - Excel file generation with formatting
- csv - Standard library for CSV handling
- datetime - Date parsing and manipulation
- collections.defaultdict - Aggregation helpers
The analytics reveal patterns like:
- Which stores you frequent most
- What time of day you typically shop
- Your most purchased items
- How much you save with promotions
- Spending by category breakdown
To add your own receipt data:
- Structure transactions in the format shown above
- Add to the
transactionslist inparse_receipts.py - Run both scripts to regenerate analytics
Personal project for spending analysis.