leftovers

This commit is contained in:
2026-05-12 11:53:02 +02:00
parent e181656f04
commit 275ca96e74
12 changed files with 1316 additions and 1 deletions
+36
View File
@@ -0,0 +1,36 @@
import csv
import random
import json
import sys
use_json = "-json" in sys.argv
try:
with open("oesterreich.csv", "r", newline="", encoding="latin-1") as f:
reader = csv.reader(f, delimiter=";")
rows = list(reader)[1:] # Header entfernen
topo = []
for row in rows:
if row[0]: # Gebirge
topo.append(row[0])
if row[2]: # Landschaften
topo.append(row[2])
topo = list(set(topo)) # Duplikate entfernen
result = []
for i in range(17):
result.append(random.sample(topo, 6))
if use_json:
with open("topo.json", "w", encoding="utf-8") as f:
json.dump(result, f, ensure_ascii=False, indent=2)
else:
with open("topo.txt", "w", encoding="utf-8") as f:
for row in result:
f.write(", ".join(row) + "\n")
except Exception as e:
print("Exception:", e)