Skip to content

Commit d67ebf7

Browse files
authored
Merge pull request #148 from Datenschule/update-mv-2
This change updates the data to the latest freely available data and prevents numbers in ids and zips from being parsed to floats before being stringified. Fixes #147
2 parents fb52281 + 106ddb0 commit d67ebf7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

jedeschule/spiders/mecklenburg_vorpommern.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
from jedeschule.spiders.school_spider import SchoolSpider
77

88

9+
def as_string(value: str):
10+
try:
11+
return str(int(value))
12+
except ValueError:
13+
return value
14+
15+
916
class MecklenburgVorpommernSpider(SchoolSpider):
1017
name = "mecklenburg-vorpommern"
1118
# The state provides the data as an Excel file. The current year's
@@ -15,7 +22,7 @@ class MecklenburgVorpommernSpider(SchoolSpider):
1522
# https://www.statistischebibliothek.de/mir/receive/MVSerie_mods_00000396
1623
# Official documentation on all available data here:
1724
# https://www.laiv-mv.de/Statistik/Veröffentlichungen/Verzeichnisse/
18-
base_url = "https://www.statistischebibliothek.de/mir/servlets/MCRFileNodeServlet/MVHeft_derivate_00006849/V034%202022%2000.xlsx"
25+
base_url = "https://www.statistischebibliothek.de/mir/servlets/MCRFileNodeServlet/MVHeft_derivate_00007470/V044%202023%2000.xlsx"
1926
start_urls = [base_url]
2027

2128
def parse(self, response):
@@ -32,10 +39,10 @@ def parse(self, response):
3239
def normalize(item: Item) -> School:
3340
return School(
3441
name=item.get("NAME1"),
35-
id="MV-{}".format(item.get("DIENSTSTELLEN-NUMMER")),
42+
id="MV-{}".format(as_string(item.get("DIENSTSTELLEN-NUMMER"))),
3643
address=item.get("STRASSE"),
3744
address2="",
38-
zip=item.get("PLZ"),
45+
zip=as_string(item.get("PLZ")).zfill(5),
3946
city=item.get("ORT"),
4047
website=item.get("INTERNET"),
4148
email=item.get("E-MAIL-ADRESSE"),

0 commit comments

Comments
 (0)