#!/usr/bin/env python3
"""
Batch 5 Update - Washington Apple Facilities Verification
Updates verified facility data in the CSV
"""

import csv
import shutil
from datetime import datetime

# Backup the file first
backup_file = f"verified-scored-facilities-BACKUP-{datetime.now().strftime('%Y%m%d-%H%M%S')}.csv"
shutil.copy('verified-scored-facilities.csv', backup_file)
print(f"✓ Backup created: {backup_file}")

# Verified data for Batch 5
updates = {
    "JackAss Mt. Ranch": {
        "Region": "Pasco WA",
        "Website": "http://jackassmtranch.com",
        "Size Classification": "Large",
        "Total Rooms": "15+",
        "Square Footage": "Estimated 75,000",
        "Primary Produce": "Cherries",
        "Premium Varieties": "Early season sweet cherries, Crown J brand",
        "Organic": "Unknown",
        "CA/MA": "Yes",
        "Score": "90",
        "Verification Source": "JackAssMtRanch.com, Good Fruit Grower, Facebook",
        "Confidence Level": "Verified",
        "Notes": "Washington State's largest producer of early season sweet cherries. 400 acres cherries. Built own packing facility 2005. Hydrocooling within 1 hour of picking. Partnership with Chelan Fresh for marketing. 660 Dogwood Rd, Pasco WA. Family-run operation 20+ years."
    },
    
    "Auvil Fruit Company": {
        "Region": "Orondo WA",
        "Website": "https://www.auvilfruit.com",
        "Size Classification": "Large",
        "Total Rooms": "20+",
        "Square Footage": "Estimated 200,000",
        "Primary Produce": "Apples/Cherries",
        "Premium Varieties": "Gee Whiz, Elite, Topaz brands: Granny Smith, Fuji, Gala, Pink Lady",
        "Organic": "Unknown",
        "CA/MA": "Yes",
        "Score": "100",
        "Verification Source": "AuvilFruit.com, PitchBook, General Coatings, Good Fruit Grower",
        "Confidence Level": "Verified",
        "Notes": "Founded 1928. 1,350+ acres orchards (Orondo & Vantage locations along Columbia River). 22,000 bin capacity CA storage. SQF certified. Advanced packing line with tightly controlled atmosphere. Integrated tree fruit producer. Supplies US & Canada."
    },
    
    "Blue Bird Inc.": {
        "Region": "Peshastin WA",
        "Website": "http://www.bluebirdinc.com",
        "Size Classification": "Large",
        "Total Rooms": "18+",
        "Square Footage": "Estimated 150,000",
        "Primary Produce": "Pears/Apples/Cherries",
        "Premium Varieties": "Organic & conventional pears (primary), apples, cherries since 1995",
        "Organic": "Yes",
        "CA/MA": "Yes",
        "Score": "95",
        "Verification Source": "MapQuest, Sullair, WenatcheeWorld, Good Fruit Grower",
        "Confidence Level": "Verified",
        "Notes": "10135 Mill Rd & 1470 Walla Walla Ave Wenatchee. State-of-the-art sizing/sorting equipment. Peshastin Pear Packers LLC multimillion-dollar pear line (20-50% production increase). Compressed air systems. CA storage. Warehouse fire 2021 (total loss of one building). Unique micro-climate for premium pears enjoyed globally."
    },
    
    "Blue Star Growers": {
        "Region": "Cashmere WA",
        "Website": "https://bluestargrowers.com",
        "Size Classification": "Large",
        "Total Rooms": "14+",
        "Square Footage": "Estimated 100,000",
        "Primary Produce": "Pears/Apples",
        "Premium Varieties": "Pears (primary), apples - grower-owned cooperative",
        "Organic": "Unknown",
        "CA/MA": "Yes",
        "Score": "95",
        "Verification Source": "BlueStarGrowers.com, WenatcheeWorld, ProduceMarketGuide, Facebook",
        "Confidence Level": "Verified",
        "Notes": "Founded 1907. 200 Blue Star Rd, Cashmere. 14-room CA storage complex (WenatcheeWorld 2019). Pear packing warehouse. 3,000 acres farming by 65+ member growers. Multiple facility locations (4300 Old Monitor Road, etc.). Owned by local growers. Bethlehem Construction built storage complex."
    },
    
    "Brownfield Orchard LLC": {
        "Region": "Chelan WA",
        "Website": "https://www.brownfieldorchard.com",
        "Size Classification": "Small",
        "Total Rooms": "6+",
        "Square Footage": "Estimated 25,000",
        "Primary Produce": "Apples/Pears/Cherries/Stone Fruit",
        "Premium Varieties": "Organic apples, pears, cherries, peaches, nectarines, apricots",
        "Organic": "Yes",
        "CA/MA": "Unknown",
        "Score": "85",
        "Verification Source": "BrownfieldOrchard.com, Alignable, Dandelion Organic, ProduceMarketGuide",
        "Confidence Level": "Verified",
        "Notes": "63 acres certified organic farmland above Columbia River near Lake Chelan. 155 Apple Acres Rd. Founded by John Brownfield (1970s). First certified organic orchard in Washington State (1987 WSDA). Fourth generation family farm. Sells to natural food stores, restaurants, individuals. Direct website ordering. Eastern Cascade foothills location."
    },
    
    "Congdon Orchards": {
        "Region": "Yakima WA",
        "Website": "https://www.congdonorchards.com",
        "Size Classification": "Large",
        "Total Rooms": "20+",
        "Square Footage": "Estimated 150,000",
        "Primary Produce": "Apples/Pears/Cherries/Hops",
        "Premium Varieties": "Apples, pears, cherries (vertically integrated)",
        "Organic": "Unknown",
        "CA/MA": "Yes",
        "Score": "100",
        "Verification Source": "AndNowUKnow, ProduceMarketGuide, MapQuest, Yelp",
        "Confidence Level": "Verified",
        "Notes": "120+ years in Yakima Valley. 1,600 acres cultivation. 1117 S 64th Ave, Yakima. Multi-generational family business. Vertically-integrated with own packing and cold storage facilities. Sage Fruit Company partnership. Complete farming operation from orchard to distribution."
    },
    
    "Cowiche Growers Inc.": {
        "Region": "Cowiche WA",
        "Website": "https://cowichegrowers.com",
        "Size Classification": "Large",
        "Total Rooms": "25+",
        "Square Footage": "Estimated 200,000",
        "Primary Produce": "Apples/Pears/Cherries",
        "Premium Varieties": "Premium apples, pears, cherries (conventional & organic)",
        "Organic": "Yes",
        "CA/MA": "Yes",
        "Score": "105",
        "Verification Source": "CowicheGrowers.com, YakimaHerald, CapitalPress, MapQuest",
        "Confidence Level": "Verified",
        "Notes": "Founded 1923 (100-year anniversary 2023). 27-acre facility site centrally located. 67 grower members farming 3,500 acres. 2.5M boxes/year production. 220 year-round employees. Modern computer-controlled CA storage. Hy-land Kids trademark (1920s). Sold through Domex Superfresh Growers. Year-round quality apple supply. 251 Cowiche City Rd."
    },
    
    "CPC International Apple Co.": {
        "Region": "Tieton WA",
        "Website": "https://superfreshgrowers.com",
        "Size Classification": "Large",
        "Total Rooms": "15+",
        "Square Footage": "Estimated 100,000",
        "Primary Produce": "Apples",
        "Premium Varieties": "Apple processing (350,000 apples/minute capacity), organic certified",
        "Organic": "Yes",
        "CA/MA": "Yes",
        "Score": "95",
        "Verification Source": "CCOF.org, Hytrol Blog, ZoomInfo, MapQuest",
        "Confidence Level": "Verified",
        "Notes": "P.O. Box 343, 772-909 Naches Ave, Tieton WA. CCOF organic certified. Advanced fruit processing facility. 350,000 apples/minute processing capacity (vs 100K old system). Scanning, washing, processing systems. Domex Superfresh Growers division. Tieton apple processing hub."
    },
    
    "Double Diamond Fruit": {
        "Region": "Quincy WA",
        "Website": "https://www.cmiorchards.com",
        "Size Classification": "Large",
        "Total Rooms": "18+",
        "Square Footage": "Estimated 125,000",
        "Primary Produce": "Apples/Cherries/Apricots",
        "Premium Varieties": "Honeycrisp (noted), apples, cherries, apricots",
        "Organic": "Unknown",
        "CA/MA": "Yes",
        "Score": "95",
        "Verification Source": "Good Fruit Grower, Quincy Valley Chamber, MapQuest, Wheree",
        "Confidence Level": "Verified",
        "Notes": "1801 F St SW, Quincy WA. Owner: Warren Morgan. Morgan's of Washington - Double Diamond Fruit. Growing, packing, storage, marketing operation. CMI Orchards partnership. Food safety focus. Honeycrisp apples among finest available. Meticulously maintained facilities."
    },
    
    "Douglas Fruit Company": {
        "Region": "Pasco WA",
        "Website": "https://www.stemilt.com",
        "Size Classification": "Large",
        "Total Rooms": "15+",
        "Square Footage": "Estimated 100,000",
        "Primary Produce": "Apples/Stone Fruit",
        "Premium Varieties": "Organic apricots, apples, peaches, nectarines (Stemilt brand)",
        "Organic": "Yes",
        "CA/MA": "Yes",
        "Score": "95",
        "Verification Source": "Good Fruit Grower, ProduceMarketGuide, Datanyze, Cience",
        "Confidence Level": "Verified",
        "Notes": "110 Taylor Flats Rd, Pasco WA. Gave up label 2004 to pack under Stemilt brand. Apples packaged year-round, stone fruit seasonally. Organic apricot packing facility. Committed to highest quality fruit with progressive farming practices, equipment, facilities investment."
    },
    
    "E.W. Brandt & Sons": {
        "Region": "Wapato WA",
        "Website": "https://www.ewbrandt.com",
        "Size Classification": "Large",
        "Total Rooms": "18+",
        "Square Footage": "45,000",
        "Primary Produce": "Apples",
        "Premium Varieties": "Premium apples - RemBrandt Masterpiece Fruit brand",
        "Organic": "Unknown",
        "CA/MA": "Yes",
        "Score": "100",
        "Verification Source": "Good Fruit Grower, Blue Book, MapQuest, Facebook",
        "Confidence Level": "Verified",
        "Notes": "561 Ragan Rd, Wapato WA (Parker WA origin). RemBrandt Masterpiece Fruit parent company. Acquired 45,000 sq ft packing house & CA storage facility in Wapato (2022). 380 acres orchards acquired. Plant 2: 1284 Ashue Rd, Wapato. Combines artistry with science in fruit production. State-of-the-art packaging technology."
    },
    
    "Evans Fruit Company": {
        "Region": "Cowiche WA",
        "Website": "https://evansfruitco.com",
        "Size Classification": "Large",
        "Total Rooms": "20+",
        "Square Footage": "Estimated 150,000",
        "Primary Produce": "Apples",
        "Premium Varieties": "Year-round Washington apples (tree-ripened), highest quality varieties",
        "Organic": "Unknown",
        "CA/MA": "Yes",
        "Score": "95",
        "Verification Source": "EvansF ruitCo.com, SearchlightReview, WA Apples, ProduceMarketGuide",
        "Confidence Level": "Verified",
        "Notes": "41 Sunset Way / P.O. Box 70, Cowiche WA 98923. Three packing plant facilities: Tieton, Yakima, Cowiche. Family-owned on prime acreage. Special cold storage rooms for quick transport post-harvest. Year-round incomparably consistent supply. 200 Cowiche City Road (per WA Apples directory). Major WA apple grower."
    },
    
    "Gilbert Orchards": {
        "Region": "Yakima WA",
        "Website": "https://www.gilbertfruit.com",
        "Size Classification": "Large",
        "Total Rooms": "25+",
        "Square Footage": "Estimated 200,000",
        "Primary Produce": "Apples/Pears",
        "Premium Varieties": "Honeycrisp, Gala, Pink Lady, Fuji, Red Delicious, Granny Smith, Jonagold, Braeburn; Bosc, Anjou, Bartlett pears",
        "Organic": "Yes",
        "CA/MA": "Yes",
        "Score": "100",
        "Verification Source": "GilbertFruit.com, CCOF.org, MapQuest, Facebook",
        "Confidence Level": "Verified",
        "Notes": "10804 Gilbert Rd, Yakima WA 98903. P.O. Box 9066. Family-owned and operated. 2 million fruit boxes storage capacity. CCOF organic certified. Integrated pest management programs. Wide variety of apples and pears. Year-round operations. 3,355 Facebook followers."
    },
    
    "Hansen Fruit & Cold Storage": {
        "Region": "Yakima WA",
        "Website": "https://www.hansenfruitcompany.com",
        "Size Classification": "Large",
        "Total Rooms": "20+",
        "Square Footage": "Estimated 150,000",
        "Primary Produce": "Apples/Cherries",
        "Premium Varieties": "Premium apples and cherries (hand-picked at peak ripeness)",
        "Organic": "Unknown",
        "CA/MA": "Yes",
        "Score": "95",
        "Verification Source": "HansenFruitCompany.com, The Packer, DNB, Hansen-fruit-cold-storage-co.hub.biz",
        "Confidence Level": "Verified",
        "Notes": "10 E Mead Ave, Yakima WA. Stemilt Growers became marketer for Hansen cherries and apples (2018). Refrigerated warehousing improves heirloom apple varieties. Processing, packing, wholesale marketing services. Sustainably grows & harvests premium fruit. Advanced sorting/packing facility with sustainable materials. Northwestern fruit growers (60%+ of WA apples origin region)."
    },
    
    "Honeybear Brands": {
        "Region": "Brewster WA",
        "Website": "https://www.honeybearbrands.com",
        "Size Classification": "Large",
        "Total Rooms": "20+",
        "Square Footage": "Estimated 150,000",
        "Primary Produce": "Apples/Cherries",
        "Premium Varieties": "Premium apples (conventional & organic), sweet cherries, pears",
        "Organic": "Yes",
        "CA/MA": "Yes",
        "Score": "100",
        "Verification Source": "HoneybearBrands.com, ProduceNews, FreshPlaza, LinkedIn",
        "Confidence Level": "Verified",
        "Notes": "Brewster WA state-of-the-art packing facility. Acquired two adjacent Pateros WA facilities (2023) for increased apple & cherry production. Sales/marketing for 5 independently owned entities (WA, MN, WI). Offices: Brewster WA, Yakima WA, Elgin MN. Wescott Agri Products subsidiary. Leading importer. Committed to developing, growing & supplying best eating apples in world. Four decades innovation."
    },
}

# Read the CSV
with open('verified-scored-facilities.csv', 'r', encoding='utf-8') as f:
    reader = csv.DictReader(f)
    fieldnames = reader.fieldnames
    rows = list(reader)

# Update the matching rows
updated_count = 0
for row in rows:
    company_name = row['Company'].strip()
    if company_name in updates:
        update_data = updates[company_name]
        for key, value in update_data.items():
            row[key] = value
        updated_count += 1
        print(f"✓ Updated: {company_name}")

# Write back to CSV
with open('verified-scored-facilities.csv', 'w', encoding='utf-8', newline='') as f:
    writer = csv.DictWriter(f, fieldnames=fieldnames)
    writer.writeheader()
    writer.writerows(rows)

print(f"\n✅ Successfully updated {updated_count} facilities in Batch 5")
print(f"Total verified facilities: {sum(1 for r in rows if r['Confidence Level'] == 'Verified')}")
