Upload sample_data_seed.py
Browse files- sample_data_seed.py +54 -0
sample_data_seed.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os, json ,csv
|
| 2 |
+
|
| 3 |
+
BLOG_MD = """# Tokyo local food pickes
|
| 4 |
+
## Tsukiji Outer Market
|
| 5 |
+
Fresh sushi, street food, great for Food, outdoor.
|
| 6 |
+
## TeamLab Planets
|
| 7 |
+
Immersive art museum, perfect for Culture, indoor.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
REVIEWS = [
|
| 11 |
+
{
|
| 12 |
+
"title": "Tukiji Outer Market",
|
| 13 |
+
"text": "Vibrant market with many stalls. Best in the morning. Food,outdoor",
|
| 14 |
+
"rating": 4.6,
|
| 15 |
+
"lat": 35.6655,
|
| 16 |
+
"lon": 139.7708,
|
| 17 |
+
"url": "https://example.com/tsukiji",
|
| 18 |
+
"tag":["Food", "outdoor"]
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"title": "teamLab Planets",
|
| 22 |
+
"text": "Immersive digital art museum. Reserve tickets. Culture, indoor",
|
| 23 |
+
"rating": 4.7,
|
| 24 |
+
"lat": 35.6457,
|
| 25 |
+
"lon": 139.7823,
|
| 26 |
+
"url": "https://example.com/teamlab",
|
| 27 |
+
"tag":["Culture", "indoor"]
|
| 28 |
+
},
|
| 29 |
+
]
|
| 30 |
+
|
| 31 |
+
EVENTS =[
|
| 32 |
+
["Sumida River Fireworks", "River fireworks festival(summer)", "2025-07-26", "2025-07-26", 35.7100, 139.8107, "https://example.com//fireworks", "outdoor,festival","Tokyo"]
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
def seed():
|
| 36 |
+
os.makedirs("data/blogs",exist_ok=True)
|
| 37 |
+
os.makedirs("data/reviews", exist_ok=True)
|
| 38 |
+
os.makedirs("data/events", exist_ok=True)
|
| 39 |
+
|
| 40 |
+
with open("data/blogs/local.md", "w",encoding="utf-8") as f:
|
| 41 |
+
f.write(BLOG_MD)
|
| 42 |
+
|
| 43 |
+
with open("data/reviews/reviews.jsonl", "w", encoding="utf-8") as f:
|
| 44 |
+
for r in REVIEWS:
|
| 45 |
+
f.write(json.dumps(r, ensure_ascii=False) + "\n")
|
| 46 |
+
|
| 47 |
+
with open("data/events/events.csv", "w", encoding="utf-8", newline="") as f:
|
| 48 |
+
w = csv.writer(f)
|
| 49 |
+
w.writerow(["title", "description", "start", "end", "lat", "lon", "url", "tags", "city"])
|
| 50 |
+
for row in EVENTS:
|
| 51 |
+
w.writerow(row)
|
| 52 |
+
|
| 53 |
+
return 1 + len(REVIEWS) +len(EVENTS)
|
| 54 |
+
|