Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. [Skript]RKI-Impfquotenmonitoring Deutschland incl. B-länder

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    [Skript]RKI-Impfquotenmonitoring Deutschland incl. B-länder

    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      morpheus 0 @klassisch last edited by

      Es gibt jetzt eine Version
      https://github.com/iobroker-community-adapters/ioBroker.coronavirus-statistics

      Jetzt funktioniert alles wieder einwandfrei 🙂

      K 1 Reply Last reply Reply Quote 0
      • K
        klassisch Most Active @morpheus 0 last edited by

        @morpheus-0 bei mir auch, vielen Dank!

        1 Reply Last reply Reply Quote 0
        • Dutchman
          Dutchman Developer Most Active Administrators @fastfoot last edited by

          @fastfoot sagte in [Skript]RKI-Impfquotenmonitoring Deutschland incl. B-länder:

          @morpheus-0 Bitte LOG Ausgaben in Code Tags!

          Das Problem liegt wohl an der geänderten Website

          @klassisch sagte in [Skript]RKI-Impfquotenmonitoring Deutschland incl. B-länder:

          @fastfoot bei mir das gleiche

          verwechselt bitte script nicht mit adapter, issues zu adapter bitte am besten immer git oder im betreffenden thread.
          Obwohl in diesem fall zufällig @fastfoot auch fast gleichzeitig ne Lesung parat hatte 🙂

          sissiwup 1 Reply Last reply Reply Quote 0
          • sissiwup
            sissiwup @Dutchman last edited by sissiwup

            Mann, heute schon wieder eine Anpassung.
            Die Reiter sind mal wieder umbenannt worden...
            Habs oben im Skript angepaßt.

            sissiwup 1 Reply Last reply Reply Quote 0
            • sissiwup
              sissiwup @sissiwup last edited by

              @sissiwup
              Und wieder mal neu, jetzt werden Formeln in der Excel verwendet.

              1 Reply Last reply Reply Quote 0
              • F
                fraltho last edited by

                aktuell (seit ca. einer Woche) werden die Impfungen nicht mehr aktualisiert, generell? Oder nur bei mir und einigen wenigen anderen Kollegen?

                Mfg
                Frank

                F 1 Reply Last reply Reply Quote 0
                • F
                  fastfoot @fraltho last edited by

                  @fraltho sagte in [Skript]RKI-Impfquotenmonitoring Deutschland incl. B-länder:

                  aktuell (seit ca. einer Woche) werden die Impfungen nicht mehr aktualisiert, generell? Oder nur bei mir und einigen wenigen anderen Kollegen?

                  das obige Skript ist seit der Implementierung im Adapter eh obsolet und läuft auch mit den aktuellen Versionen des RKI Excelsheet nicht mehr. Das gleiche Problem hat wohl auch der Adapter, die RKI Leute wechseln das Layout ständig und auch nicht gerade auswertefreundlich. Leider ist das Excel die einzige mir bekannte Quelle für Impfdaten auf Bundeslandebene. Inwiefern @Dutchman da jetzt Änderungen im Adapter macht kann ich nicht sagen, meines Wissens wollte er sich das aber ansehen.

                  F 1 Reply Last reply Reply Quote 0
                  • F
                    fraltho @fastfoot last edited by

                    @fastfoot es gibt ja ein issue darüber, warten wir also ab 🙂

                    1 Reply Last reply Reply Quote 0
                    • M
                      morpheus 0 @fastfoot last edited by

                      @fastfoot
                      Hallo @fastfoot: Leider wurde die Excelliste anscheinend schon wieder angepasst. Und die Zahlen passen nicht zusammen. Kannst Du mal einen Blick darauf werfen?

                      343f0294-0e9c-40f6-b477-ae8085ab726c-image.png

                      5bd4a36e-0088-4b2d-9426-045f6aa4354f-image.png

                      Danke
                      Gruß Christian

                      F 1 Reply Last reply Reply Quote 0
                      • F
                        fastfoot @morpheus 0 last edited by

                        @morpheus-0 Für den Covid Adapter ist ausschließlich @Dutchman zuständig, dies hier ist der Thread zum Skript, welches allerdings zur Zeit nicht weiterentwickelt wird und deshalb auch nicht funktioniert. Sorry dass ich da keine besseren Neuigkeiten habe

                        sissiwup 1 Reply Last reply Reply Quote 0
                        • sissiwup
                          sissiwup @fastfoot last edited by

                          Hi,

                          hier mal die aktuelle Version:
                          getImpfquoten.py:

                          import openpyxl
                          from pathlib import Path
                          import requests
                          import os,sys
                          import csv
                          from datetime import datetime
                          
                          url = "https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquotenmonitoring.xlsx;jsessionid=159D4550C958EDFAA9A49921FA132A35.internet122?__blob=publicationFile"
                          # url = "https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquotenmonitoring.xlsx"
                          r = requests.get(url, allow_redirects=True)
                          open(r'/var/skripte/data/Impfquotenmonitoring.xlsx', 'wb').write(r.content)
                          xlsx_file = Path(os.getcwd(), r'/var/skripte/data/Impfquotenmonitoring.xlsx')
                          wb_obj = openpyxl.load_workbook(xlsx_file,data_only=True)
                          
                          datakt=datetime.now()
                          dat="--"
                          sheet=wb_obj.active
                          for sht in wb_obj:
                              print(sht.title)
                              try:
                                  dat = datetime.strptime(sht.title[-8:],'%d.%m.%y')
                                  sheet=sht
                              except:
                                  pass
                          print("Selected: "+sheet.title)
                          # print(dat)
                          
                          if dat=="--":
                              print("Datum nicht ermittelbar!")
                              sys.exit(99)
                          
                          #sheet = wb_obj.active
                          sum = 0
                          anzbl = 0
                          titel = 0
                          headline = None
                          with open(r'/var/skripte/data/Impfquotenmonitoring.csv', 'w', newline="") as f:
                              c = csv.writer(f)
                              for row in sheet.iter_rows(min_row=1,max_col=25,max_row=19, values_only=True):
                                  try:
                                      sum=sum+row[2]
                                      nrow=[str(dat.date()),str(datakt),str(datetime.timestamp(dat))]
                                      anzbl=anzbl+1
                                      row = [x for x in row if x is not None]
                                      nrow.extend(list(row))
                                      if titel==0:
                                          titel=1
                                          headline = [x for x in headline if x is not None]
                                          trow=['Datenstand','Dat-Import', 'Datenstand-Unix']
                                          trow.extend(list(headline))
                                          print(trow)
                                          c.writerow(trow)
                          
                                      print(nrow)
                                      c.writerow(nrow)
                                  except:
                                      if headline==None:
                                          headline=list(row)
                                      else:
                                          for i in range(0,len(headline)):
                                              if row[i] is not None:
                                                  if headline[i] is None:
                                                      headline[i]=row[i]
                                                  else:
                                                      headline[i]=headline[i]+"."+row[i]
                          
                          if anzbl!=16:
                              print("Es sollten 16 Bundesländer sein:",anzbl)
                              sys.exit(99)
                          
                          if len(headline)!=15:
                              print("Anzahl Spalten sollte 15 sein:",len(headline))
                              sys.exit(99)
                          
                          print("Gesamtzahl der Impfungen in Deutschland: " + str(sum))
                          print("Datenstand: " + str(dat) + " Sheetname:" + str(sheet.title))
                          

                          getImpfquoten.sh:

                          #!/bin/bash
                          NOW=`date +"%d.%m.%g %H:%M.%S"`
                          NOWDAT=`date +"%u"`
                          USER=usermysql
                          PASS=passwordmysql
                          
                          echo "Starte Abgleich: $NOW"
                          
                          rm /var/skripte/data/Impfquotenmonitoring.csv
                          rm /var/skripte/data/Impfquotenmonitoring.xlsx
                          rm /var/skripte/data/cor_impfung.csv
                          python3.9 -u /var/skripte/getImpfquoten.py
                          if [ $? -eq 99 ]
                          then
                          	echo "Fehler bei Datenabholung"
                          	cp /var/skripte/data/Impfquotenmonitoring.xlsx /var/skripte/data/Impquotenmonitoring_$NOWDAT.xlsx.backup
                                  cp /var/skripte/data/Impfquotenmonitoring.csv /var/skripte/data/Impfquotenmonitoring_$NOWDAT.csv.backup
                          	exit 99
                          fi
                          cp /var/skripte/data/Impfquotenmonitoring.csv /var/skripte/data/Impfquotenmonitoring_$NOWDAT.csv.backup
                          cp /var/skripte/data/Impfquotenmonitoring.csv /var/skripte/data/cor_impfung.csv
                          echo "Starte Import $NOW"
                          
                          mysqlimport --fields-terminated-by=, --ignore-lines=1 --verbose --ignore --local -u $USER -p$PASS iobroker /var/skripte/data/cor_impfung.csv
                          
                          mysql -u $USER -p$PASS iobroker -e "DELETE i1.* from cor_impfung i1 inner join cor_impfung i2 on (i1.datenstand=i2.datenstand and i1.rs=i2.rs and i1.import_datum<i2.import_datum)"
                          mysql -u $USER -p$PASS iobroker -e "UPDATE cor_impfung inner join cor_bundesland on rs=lan_ew_ags SET Bundesland=lan_ew_gen"
                          

                          Tabelle:

                          CREATE TABLE `cor_impfung` (
                            `datenstand` date NOT NULL DEFAULT current_timestamp(),
                            `import_datum` datetime NOT NULL DEFAULT current_timestamp(),
                            `datenstand_unix` bigint(20) NOT NULL DEFAULT 0,
                            `RS` int(11) NOT NULL DEFAULT -1,
                            `Bundesland` mediumtext COLLATE utf8_bin NOT NULL DEFAULT '\'"??"\'',
                            `Gesamtimpfungen` int(11) NOT NULL DEFAULT 0,
                            `Impfungen` int(11) DEFAULT 0,
                            `BioNTech` int(11) NOT NULL DEFAULT 0,
                            `Moderna` int(11) NOT NULL DEFAULT 0,
                            `AstraZeneca` int(11) NOT NULL DEFAULT 0,
                            `Differenz_Vortag` int(11) DEFAULT 0,
                            `Impfquote` double NOT NULL DEFAULT 0,
                            `Zweitimpfung` int(11) NOT NULL DEFAULT 0,
                            `BioNTech_2` int(11) NOT NULL DEFAULT 0,
                            `Moderna_2` int(11) NOT NULL DEFAULT 0,
                            `AstraZeneca_2` int(11) NOT NULL DEFAULT 0,
                            `Zweit_Differenz_Vortag` int(11) NOT NULL DEFAULT 0,
                            `Impfquote_2` double NOT NULL DEFAULT 0
                          ) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
                          

                          Index:

                          ALTER TABLE `cor_impfung`
                            ADD PRIMARY KEY (`datenstand`,`Bundesland`(24),`import_datum`),
                            ADD KEY `datenstand-unix` (`datenstand_unix`,`Bundesland`(24));
                          COMMIT;
                          

                          Erklärung siehe oben bei meinem letzten Post

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post

                          Support us

                          ioBroker
                          Community Adapters
                          Donate

                          386
                          Online

                          31.8k
                          Users

                          80.0k
                          Topics

                          1.3m
                          Posts

                          7
                          31
                          2078
                          Loading More Posts
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes
                          Reply
                          • Reply as topic
                          Log in to reply
                          Community
                          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                          The ioBroker Community 2014-2023
                          logo