-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_test_data.py
More file actions
88 lines (73 loc) · 3.3 KB
/
Copy pathgenerate_test_data.py
File metadata and controls
88 lines (73 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python3
"""
Generate test Excel file for MushLog import testing
"""
import pandas as pd
import os
from datetime import datetime, timedelta
import random
def generate_test_data():
"""Generate sample mycology data for testing"""
# Sample data
data = []
# Generate 10 sample specimens
for i in range(1, 11):
# Generate a random date within the last 6 months
days_ago = random.randint(0, 180)
date = (datetime.now() - timedelta(days=days_ago)).strftime("%Y-%m-%d")
specimen = {
'id': f"ML{i:04d}",
'date': date,
'state': random.choice(['California', 'Oregon', 'Washington', 'Colorado']),
'county': random.choice(['Marin', 'Sonoma', 'Mendocino', 'Humboldt', 'Jefferson']),
'city': random.choice(['San Francisco', 'Oakland', 'Berkeley', 'Arcata', 'Eureka']),
'site_name': random.choice(['Redwood Regional Park', 'Muir Woods', 'Point Reyes', 'Golden Gate Park', 'Tilden Regional Park']),
'species': random.choice([
'Amanita muscaria',
'Boletus edulis',
'Cantharellus cibarius',
'Lactarius deliciosus',
'Russula emetica',
'Pleurotus ostreatus',
'Agaricus bisporus',
'Coprinus comatus',
'Morchella esculenta',
'Gyromitra esculenta'
]),
'field_photo': random.choice(['Yes', 'No']),
'nearby_trees': random.choice(['Oak', 'Pine', 'Redwood', 'Douglas Fir', 'Mixed']),
'substrate': random.choice(['Soil', 'Wood', 'Leaf litter', 'Moss', 'Grass']),
'habit': random.choice(['Solitary', 'Scattered', 'Clustered', 'Gregarious']),
'odor': random.choice(['None', 'Mild', 'Strong', 'Pleasant', 'Unpleasant']),
'taste': random.choice(['None', 'Mild', 'Bitter', 'Sweet', 'Nutty']),
'inat_id': str(random.randint(1000000, 9999999)) if random.random() > 0.3 else 'None',
'collected_by': random.choice(['John Smith', 'Jane Doe', 'Bob Wilson', 'Alice Brown', 'Charlie Davis'])
}
data.append(specimen)
return data
def create_test_excel():
"""Create test Excel file"""
# Generate data
data = generate_test_data()
# Create DataFrame
df = pd.DataFrame(data)
# Create filename with timestamp
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
filename = f"mushlog_test_data_{timestamp}.xlsx"
# Save to Excel
df.to_excel(filename, index=False, engine='openpyxl')
print(f"✅ Test Excel file created: {filename}")
print(f"📊 Contains {len(data)} sample specimens")
print(f"📁 File location: {os.path.abspath(filename)}")
print("\n📋 Sample data preview:")
print(df.head(3).to_string(index=False))
return filename
if __name__ == "__main__":
try:
filename = create_test_excel()
print(f"\n🎯 You can now use '{filename}' to test the import tool!")
print("💡 Try both 'Replace Database' and 'Merge Data' modes")
except Exception as e:
print(f"❌ Error creating test file: {e}")
print("💡 Make sure you have pandas and openpyxl installed:")
print(" pip install pandas openpyxl")