-
Notifications
You must be signed in to change notification settings - Fork 11
/
stats.py
66 lines (61 loc) · 1.43 KB
/
stats.py
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
import datetime
import pathlib
WEEKDAYS = (
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday",
)
KINDS = {
"(Estatal)": "Spain",
"(Local)": "City",
"(Autonómica)": "Autonomous community",
"(Autonòmica)": "Autonomous community",
}
print(
"\t".join(
(
"country",
"autonomous_community",
"city",
"year",
"month",
"day",
"weekday number",
"weekday name",
"date",
"kind",
"name",
)
)
)
for f in pathlib.Path(".").glob("*/*/*/*/*.cal"):
if str(f) in (
"data/España/Comunitat Valenciana/Paterna/2022.cal",
"data/España/Comunitat Valenciana/Burjassot/2022.cal",
):
continue
for line in f.read_text().splitlines():
if line.startswith("#"):
continue
date, rest = line.split(" ", 1)
name, kind = rest.rsplit(" ", 1)
date = datetime.date.fromisoformat(date)
_, country, autonomous_community, city, _ = f.parts
row = (
country,
autonomous_community,
city,
date.year,
date.month,
date.day,
date.weekday(),
WEEKDAYS[date.weekday()],
date.isoformat(),
KINDS[kind],
name,
)
print("\t".join(map(str, row)))