MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    read csv-data and put it in an array

    Scheduled Pinned Locked Moved Utilities
    313 Posts 3 Posters 446.1k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      sdetweil @Perlchamp
      last edited by

      @Perlchamp see my updated post above

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      1 Reply Last reply Reply Quote 0
      • PerlchampP Offline
        Perlchamp
        last edited by

        i get this for each entry (here i only posted one of them):

        [2020-05-02 17:50:36.803] [LOG]    LOOK >>>>>>{} (/home/dirk/MagicMirror/modules/MMM-Logging/node_helper.js:34 Class.socketNotificationReceived)
        

        empty: {}

        S 1 Reply Last reply Reply Quote 0
        • S Offline
          sdetweil @Perlchamp
          last edited by sdetweil

          @Perlchamp ok, so the data collection didn’t work…

          so I would step thru that code

          what is the 1st row of your csv file? the column headers

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • PerlchampP Offline
            Perlchamp
            last edited by

            before you do this. stop. i make an error. the code you posted is not in the notification section. it’s in the getDom section … so i placed it there. was this wrong ?

            S 1 Reply Last reply Reply Quote 0
            • S Offline
              sdetweil @Perlchamp
              last edited by

              @Perlchamp there is NOT an this. updateDom() in the getDom() section…

              still doesn’t change the result… there are no birthdays found that match 02/05

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 0
              • PerlchampP Offline
                Perlchamp
                last edited by

                the columns are:
                birth, name

                and is called “birthdays.csv”

                the data are:
                23.01.1987,Thomas Roth

                S 1 Reply Last reply Reply Quote 0
                • S Offline
                  sdetweil @Perlchamp
                  last edited by sdetweil

                  @Perlchamp so there are no birthdays for today… we are ONLY selecting for TODAY. not every day

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • PerlchampP Offline
                    Perlchamp
                    last edited by

                    why for TODAY ? and not for current MONTH ?
                    getDon:

                    	getDom: function() {
                    		var self = this;
                    		var wrapper = document.createElement("div");
                    		
                    		// tell MM to call and get our content
                    Log.log("LOOK >>>>>>" + JSON.stringify(this.active_birthdays))    // add this line
                    			self.updateDom();                          // before this line in the notification code..
                    
                    		for(var birthday of Object.keys(this.active_birthdays)) {
                    			for(var name of this.active_birthdays[birthday]) {
                    				var m = document.createElement("div");
                    				Log.log("BIRTHDAY >> " + birthday);
                    				Log.log("NAME >> " + name);
                    				m.innerText = birthday + " " + name;
                    				wrapper.appendChild(m);
                    			}
                    		}
                    
                    		// pass the created content back to MM to add to DOM.
                    		return wrapper;
                    	}
                    
                    S 1 Reply Last reply Reply Quote 0
                    • S Offline
                      sdetweil @Perlchamp
                      last edited by

                      @Perlchamp said in read csv-data and put it in an array:

                        // tell MM to call and get our content
                      

                      Log.log(“LOOK >>>>>>” + JSON.stringify(this.active_birthdays)) // add this line
                      self.updateDom();

                      not that way

                      			      // save the persons name and age on the list
                      			      self.active_birthdays[birth_date].push({'name':birthday.name, 'age': now.diff(moment(birthday.birth,'DD.MM.YYYY'), 'years') })			     
                      			   }
                      			}
                           
                      			// tell MM to call and get our content
                      Log.log(JSON.stringify(this.active_birthdays))		  // add this line	
                      			self.updateDom();                 // before this line        
                      		}     		
                      

                      sorry, didn’t see the ‘month’.

                      still doesn’t matter, that birthday is for january, so nothing to show for may

                      change this compare to do only month

                      		  // if the date is the same or later, don't use time of day
                      		   if(birth_date_moment.startOf('day').isSameOrAfter(now.startOf('day')) &&
                      		   	  birth_date_moment.startOf('day').isSameOrBefore(birthday_time_window.startOf('day'))
                      

                      hint, google get month from moment

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      1 Reply Last reply Reply Quote 0
                      • PerlchampP Offline
                        Perlchamp
                        last edited by

                        i got this:

                        [2020-05-02 18:10:50.465] [LOG]    {} (/home/dirk/MagicMirror/modules/MMM-Logging/node_helper.js:34 Class.socketNotificationReceived)
                        

                        for each entry. i have 5 birthdays in may …

                        S 1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 5
                        • 6
                        • 7
                        • 8
                        • 9
                        • 31
                        • 32
                        • 7 / 32
                        • First post
                          Last post
                        Enjoying MagicMirror? Please consider a donation!
                        MagicMirror created by Michael Teeuw.
                        Forum managed by Sam, technical setup by Karsten.
                        This forum is using NodeBB as its core | Contributors
                        Contact | Privacy Policy