enrich data
This commit is contained in:
49
show_migration_stats.py
Normal file
49
show_migration_stats.py
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Show migration statistics"""
|
||||
import sqlite3
|
||||
|
||||
conn = sqlite3.connect('/mnt/okcomputer/output/cache.db')
|
||||
|
||||
cursor = conn.execute("""
|
||||
SELECT
|
||||
COUNT(*) as total,
|
||||
SUM(CASE WHEN year_manufactured IS NOT NULL THEN 1 ELSE 0 END) as has_year,
|
||||
SUM(CASE WHEN condition_score IS NOT NULL THEN 1 ELSE 0 END) as has_condition,
|
||||
SUM(CASE WHEN manufacturer != '' THEN 1 ELSE 0 END) as has_manufacturer,
|
||||
SUM(CASE WHEN brand != '' THEN 1 ELSE 0 END) as has_brand,
|
||||
SUM(CASE WHEN model != '' THEN 1 ELSE 0 END) as has_model
|
||||
FROM lots
|
||||
""")
|
||||
|
||||
stats = cursor.fetchone()
|
||||
|
||||
print("="*60)
|
||||
print("MIGRATION RESULTS")
|
||||
print("="*60)
|
||||
print(f"\nTotal lots: {stats[0]:,}")
|
||||
print(f"Has year: {stats[1]:,} ({100*stats[1]/stats[0]:.1f}%)")
|
||||
print(f"Has condition: {stats[2]:,} ({100*stats[2]/stats[0]:.1f}%)")
|
||||
print(f"Has manufacturer: {stats[3]:,} ({100*stats[3]/stats[0]:.1f}%)")
|
||||
print(f"Has brand: {stats[4]:,} ({100*stats[4]/stats[0]:.1f}%)")
|
||||
print(f"Has model: {stats[5]:,} ({100*stats[5]/stats[0]:.1f}%)")
|
||||
|
||||
# Show sample enriched data
|
||||
print(f"\n{'='*60}")
|
||||
print("SAMPLE ENRICHED LOTS")
|
||||
print(f"{'='*60}")
|
||||
|
||||
cursor = conn.execute("""
|
||||
SELECT lot_id, year_manufactured, manufacturer, model, condition_score
|
||||
FROM lots
|
||||
WHERE year_manufactured IS NOT NULL OR manufacturer != ''
|
||||
LIMIT 5
|
||||
""")
|
||||
|
||||
for row in cursor:
|
||||
print(f"\n{row[0]}:")
|
||||
print(f" Year: {row[1]}")
|
||||
print(f" Manufacturer: {row[2]}")
|
||||
print(f" Model: {row[3]}")
|
||||
print(f" Condition: {row[4]}")
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user