Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Frage] Excel nach json

    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

    Frage] Excel nach json

    This topic has been deleted. Only users with topic management privileges can see it.
    • Horst Böttcher
      Horst Böttcher @Horst Böttcher last edited by

      Hat wer da eine Lösung

      1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @Horst Böttcher last edited by paul53

        @Horst-Böttcher:

        wie kann man einstellen das es immer um 0:00 Uhr und 12:00 Uhr ausgelesen wird

        const csvjson = require('csvjson');
        const idJson = 'Datenpunkt-ID für Vis-Tabelle';
        const url = 'https://www.berlin.de/lageso/_assets/gesundheit/publikationen/corona/bezirkstabelle.csv';
         
        schedule('0 0,12 * * *', function() {
          request(url, function(err, resp, data) {
            if(err) log(err, 'warn');
            else {
                let json = JSON.stringify(csvjson.toObject(data, {delimiter : ';'}));
                setState(idJson, json, true);
            }
          });
        });
        
        1 Reply Last reply Reply Quote 0
        • OliverIO
          OliverIO @Horst Böttcher last edited by

          @Horst-Böttcher sagte in Frage] Excel nach json:

          UTF-8 Problem

          Beim einlesen kannst du ein encoding angeben. Dazu musst du herausfinden wie die excel kodiert wurde. Wenn es Windows ist könntest du es mal mit ISO-8859-1 probieren

          Horst Böttcher 1 Reply Last reply Reply Quote 0
          • Horst Böttcher
            Horst Böttcher @OliverIO last edited by

            @OliverIO sagte in Frage] Excel nach json:

            ISO-8859-1

            es währe net wenn sie mir sagen könnten wie man das dort einträgt

            OliverIO 1 Reply Last reply Reply Quote 0
            • OliverIO
              OliverIO @Horst Böttcher last edited by

              @Horst-Böttcher

              ich habe mal das beispiel von oben kopiert. es muss nur wenig geändert werden.

              const csvjson = require('csvjson');
              const idJson = 'Datenpunkt-ID für Vis-Tabelle';
              const url = 'https://www.berlin.de/lageso/_assets/gesundheit/publikationen/corona/bezirkstabelle.csv';
               
              request({
                url:url,
                encoding:'ISO-8859-1'
                }, function(err, resp, data) {
                  if(err) log(err, 'warn');
                  else {
                      let json = JSON.stringify(csvjson.toObject(data, {delimiter : ';'}));
                      setState(idJson, json, true);
                  }
              });
              
              F 1 Reply Last reply Reply Quote 0
              • F
                fastfoot @OliverIO last edited by

                @OliverIO sagte in Frage] Excel nach json:

                encoding:'ISO-8859-1'

                das mag der JS Adapter gar nicht und beendet sich 😞 Ich hatte mich diese Woche daran versucht und bin kläglich gescheitert

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

                  @fastfoot
                  Ohne eine Fehlermeldung?
                  Was heißt beendet. Absturz?

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

                    @OliverIO sagte in Frage] Excel nach json:

                    @fastfoot
                    Ohne eine Fehlermeldung?
                    Was heißt beendet. Absturz?

                    ja, crash. Dasselbe mit ansi und was mir sonst noch einfiel.

                    javascript.1	2020-11-06 23:48:11.901	error	(27805) TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: ISO-8859-1
                    javascript.1	2020-11-06 23:48:11.901	error	(27805) Error: Unknown encoding: ISO-8859-1
                    javascript.1	2020-11-06 23:48:11.900	error	(27805) An error happened which is most likely from one of your scripts, but the originating script could not be detected.
                    
                    OliverIO 1 Reply Last reply Reply Quote 0
                    • OliverIO
                      OliverIO @fastfoot last edited by

                      @fastfoot
                      Dann Probier mal den folgenden String
                      iso88591

                      Wenn das auch nicht geht, wirst du die Daten vorher nochmal durch iconv jagen müssen.

                      https://blog.theodo.com/2017/04/csv-excel-escape-from-the-encoding-hell-in-nodejs/

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

                        @OliverIO sagte in Frage] Excel nach json:

                        @fastfoot
                        Dann Probier mal den folgenden String
                        iso88591

                        Wenn das auch nicht geht, wirst du die Daten vorher nochmal durch iconv jagen müssen.

                        https://blog.theodo.com/2017/04/csv-excel-escape-from-the-encoding-hell-in-nodejs/

                        Danke dir sehr, auch wenn ich nicht der TE bin. Das hatte mich doch interessiert und hat mich frustriert zurückgelassen, dass ich die Lösung nicht selbst finden konnte. Mit deiner Lösung klappt es jetzt. Ginge nicht auch so etwas wie charset = xxxx ? Ich kenne mich mit Request-Headern leider gar nicht aus

                        const csvjson = require('csvjson');
                        const iconv = require('iconv-lite');
                        const idJson = '0_userdata.0.json';
                        const url = 'https://www.berlin.de/lageso/_assets/gesundheit/publikationen/corona/bezirkstabelle.csv';
                         
                        request({
                          url:url,
                          encoding:'binary'
                          }, function(err, resp, data) {
                            if(err) log(err, 'warn');
                            else {
                                data = iconv.decode(data, 'iso88591');
                                let json = JSON.stringify(csvjson.toObject(data, {delimiter : ';'}));
                                setState(idJson, json, true);
                                log(json);
                            }
                        });
                        
                        
                        1 Reply Last reply Reply Quote 0
                        • paul53
                          paul53 @Horst Böttcher last edited by

                          @Horst-Böttcher:

                          die Sonderzeichen sehen komisch aus

                          Man kann sie austauschen, da alle für ein "ö" stehen.

                                  setState(idJson, json.replace(/�/g, 'ö'), true);
                          
                          Horst Böttcher 1 Reply Last reply Reply Quote 0
                          • Horst Böttcher
                            Horst Böttcher @paul53 last edited by Horst Böttcher

                            Dann Probier mal den folgenden String
                            iso88591

                            Hat supper geklappt danke euch

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

                            Support us

                            ioBroker
                            Community Adapters
                            Donate

                            921
                            Online

                            31.9k
                            Users

                            80.2k
                            Topics

                            1.3m
                            Posts

                            5
                            21
                            1228
                            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