chore: release v1.3.0 - 京东账单支持
This commit is contained in:
40
analyzer/analyze_jd_bills.py
Normal file
40
analyzer/analyze_jd_bills.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""分析京东账单数据"""
|
||||
import json
|
||||
import sys
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
with open('../jd_bills.json', 'r', encoding='utf-8') as f:
|
||||
d = json.load(f)
|
||||
|
||||
bills = [b for b in d['data']['bills'] if b['bill_type'] == 'jd']
|
||||
print(f'Total JD bills: {len(bills)}')
|
||||
print()
|
||||
|
||||
# Review level distribution
|
||||
review_levels = {}
|
||||
for b in bills:
|
||||
lvl = b['review_level'] or 'NONE'
|
||||
review_levels[lvl] = review_levels.get(lvl, 0) + 1
|
||||
print('Review level distribution:')
|
||||
for lvl, cnt in sorted(review_levels.items()):
|
||||
print(f' {lvl}: {cnt}')
|
||||
print()
|
||||
|
||||
# Category distribution
|
||||
categories = {}
|
||||
for b in bills:
|
||||
cat = b['category']
|
||||
categories[cat] = categories.get(cat, 0) + 1
|
||||
print('Category distribution:')
|
||||
for cat, cnt in sorted(categories.items(), key=lambda x: -x[1]):
|
||||
print(f' {cat}: {cnt}')
|
||||
print()
|
||||
|
||||
# Show bills that need review
|
||||
print('Bills needing review:')
|
||||
print(f"{'Level':<5} | {'Category':<12} | {'Merchant':<20} | Description")
|
||||
print('-' * 70)
|
||||
for b in bills:
|
||||
if b['review_level']:
|
||||
print(f"{b['review_level']:<5} | {b['category']:<12} | {b['merchant'][:20]:<20} | {b['description'][:30]}")
|
||||
Reference in New Issue
Block a user