import random
import datetime

def generate_earthquake_data(start_date, end_date, file_name):
    # List of 200 real-world seismic locations, reformatted to remove commas
    locations = [
        "San Andreas Fault USA", "Cascade Range USA", "Denali Fault System Alaska USA",
        "New Madrid Seismic Zone USA", "Wasatch Fault Zone USA", "Hayward Fault California USA",
        "Guerrero Gap Mexico", "Cocos Plate Subduction Zone Mexico", "Motagua Fault Zone Guatemala",
        "Caribbean North American Plate Boundary", "Los Angeles Basin USA", "Seattle Tacoma Fault Zone USA",
        "San Juan Fault Zone Argentina", "Nazca Ridge Subduction Peru", "Cotopaxi Region Ecuador",
        "Colombian Andes Plate Boundary Colombia", "Atacama Fault Zone Chile", "Cape Fold Belt South Africa",
        "Alpine Fault New Zealand", "Hikurangi Subduction Zone New Zealand", "Papua Fold Belt Papua New Guinea",
        "Nias Islands Earthquake Zone Indonesia", "Java Trench Indonesia", "Banda Arc Indonesia",
        "Sumatra Andaman Megathrust Indonesia", "Kashmir Region India", "Himalayan Subduction Zone Nepal",
        "Chiang Mai Rift Zone Thailand", "Active Faults in Myanmar", "Red River Fault Zone Vietnam",
        "Taiwan Collision Zone Taiwan", "Ryukyu Trench Japan", "Kanto Region Fault Japan",
        "Kyushu Subduction Zone Japan", "Kuril Kamchatka Trench Russia", "Lake Baikal Rift Zone Russia",
        "Berbera Rift System Somalia", "Armenian Highlands Collision Zone Armenia", "Zagros Mountains Fault Iran",
        "Makran Subduction Zone Pakistan", "Hindu Kush Earthquake Belt Afghanistan", "Caspian Sea Collision Zone Iran",
        "Jordan Rift Valley Israel", "Dead Sea Fault Zone Israel", "Eastern Anatolian Fault Turkey",
        "Hellenic Arc Greece", "Mediterranean Subduction Complex Italy", "Pyrenees Fault System Spain",
        "Aegean Seismic Zone Greece", "Alborz Mountains Fault Zone Iran", "Ligurian Alps Italy",
        "Iceland Seismic Zone Iceland", "Mid Atlantic Ridge Atlantic Ocean", "Azores Triple Junction Portugal",
        "Reykjanes Ridge Iceland", "Scandinavian Fault Zone Norway", "Barents Sea Rift Norway",
        "East African Rift Ethiopia", "South Madagascar Seismic Zone Madagascar", "Cape Verde Rift Atlantic",
        "Victoria Seismic Belt Australia", "Bismarck Plate Subduction Zone Papua New Guinea",
        "Fiji Plate Boundary Pacific Ocean", "Solomon Islands Seismic Zone Solomon Islands",
        "New Hebrides Subduction Vanuatu", "Tonga Kermadec Arc Tonga", "Samoa Seismic Zone Pacific Ocean",
        "South Sandwich Plate Collision Zone South Sandwich Islands", "Drake Passage Convergence Zone Antarctica",
        "Scotia Plate Boundary Antarctica", "Antarctic Seismic Belt Antarctica", "Ross Sea Fault Zone Antarctica",
        "Carlsberg Ridge Indian Ocean", "East Pacific Rise Pacific Ocean", "Indian Ocean Ridge Indian Ocean",
        "Macquarie Plate Boundary Australia", "Chagos Laccadive Ridge Indian Ocean", "Moho Tectonic Zone Ethiopia",
        "Azores Cape Verde Fault Line Atlantic Ocean", "South Shetland Trench Antarctica",
        "Luale Tectonic Boundary Angola", "Banda Sea Subduction Zone Indonesia",
        "Guinea Ridge Zone Guinea", "Mauritius Seismic Area Indian Ocean", "Moluccas Sea Plate Collision Indonesia",
        "Yucatan Fault Zone Central America", "Offshore Nicaragua Subduction Zone Nicaragua",
        "Central Honduras Earthquake Belt Honduras", "Puerto Rico Trench Caribbean Plate",
        "Trinidad Seismic Zone Trinidad and Tobago", "Barbadian Subduction Area Barbados",
        "Northern Andes Seismic Belt Venezuela", "South Atlantic Rift Brazil", "Acre Seismic Boundary Brazil",
        "Rio Grande Rift Zone USA", "Offshore Baja California USA", "Guarare Seismic Region Panama",
        "Offshore Vancouver Island Subduction Canada", "Yellowstone Volcanic Zone USA",
        "Adelaide Fold Belt Australia", "Tasman Plate Boundary New Zealand", "Offshore Queensland Australia",
        "Gansu Fault Zone China", "Xian Seismic Belt China", "Tibet Rift Zone China",
        "Chengdu Seismic Zone China", "Fujian Fault Zone China", "Jiuzhaigou Seismic Area China",
        "Karakoram Fault Zone India", "Andaman Nicobar Subduction India", "Mumbai Rift Zone India",
        "Cape York Seismic Zone Papua New Guinea", "Merewether Fault Australia", "Gulf of Aden Rift Zone",
        "Oman Subduction Zone", "Ras Al Khaimah Fault Zone UAE", "Djibouti Rift Zone Africa",
        "Mogadishu Seismic Zone Somalia", "Mozambique Channel Rift Mozambique", "Botswana Seismic Zone Africa",
        "Victoria Lake Microplate Africa", "Nairobi Rift Axis Kenya", "Sumba Island Subduction Zone Indonesia"
    ]

    start = datetime.datetime.strptime(start_date, '%Y-%m-%d')
    end = datetime.datetime.strptime(end_date, '%Y-%m-%d')
    delta = end - start

    earthquake_list = []

    for i in range(delta.days + 1):
        date = start + datetime.timedelta(days=i)
        for _ in range(random.randint(2, 4)):  # Roughly 3 events per day
            magnitude = round(random.uniform(3.0, 9.5), 1)
            lat = round(random.uniform(-90, 90), 4)
            lon = round(random.uniform(-180, 180), 4)
            location = random.choice(locations)
            depth = random.randint(5, 150)
            # Format data using comma-separated values (CSV)
            earthquake_list.append(f"{date.date()},{magnitude},{lat},{lon},{location},{depth} km")

    with open(file_name, "w") as file:
        file.write("\n".join(earthquake_list))
    print(f"Earthquake data saved to {file_name}")

# Generate earthquake data from Jan 2024 to June 2025
generate_earthquake_data("2024-01-01", "2025-06-02", "EarthquakeEvents.txt")