#!/usr/bin/env python3
"""
Convert 1429 cold storage facilities for Google Sheets append
"""
import csv
import json

# Read the master file
facilities = []
with open('/Users/max/.openclaw/workspace/postharvest/usa-cold-storage-master.csv', 'r') as f:
    reader = csv.DictReader(f)
    for row in reader:
        facilities.append(row)

print(f"Loaded {len(facilities)} facilities")

# Prepare rows for sheet
# Sheet format: Company, Website, Country, Region, Primary Fruit, CA Storage, Qualified, Employee, Revenue, Notes, Contact Name, Title, Email, Phone, Source
rows = []

for f in facilities:
    row = [
        f.get('Company', ''),
        f.get('Website', ''),
        'USA',
        f.get('Region', ''),
        f.get('Primary Fruit', ''),
        f.get('Rooms', ''),  # Use Rooms data for CA Storage column
        '',  # Qualified
        '',  # Employee
        '',  # Revenue
        '10+ rooms, cold storage facility',  # Notes
        '',  # Contact Name
        '',  # Title
        '',  # Email
        f.get('Phone', ''),
        f.get('Source', '')
    ]
    rows.append(row)

# Save as JSON for gog
with open('/Users/max/.openclaw/workspace/postharvest/1429-to-add.json', 'w') as f:
    json.dump(rows, f)

print(f"Saved {len(rows)} rows to 1429-to-add.json")
print(f"\nFirst row example:")
print(rows[0])
print(f"\nLast row example:")
print(rows[-1])
