Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to replace intrementally?

    Help wanted · · · – – – · · ·
    4
    25
    165
    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.
    • Levente Horváth
      Levente Horváth last edited by

      I have a question, I’m a noob, and don’t know anything about programming. How can I lets say replace numbers from “x” to “y” in fours?
      I want to edit unix times from 1588384800 to 1588393920 and change the date to the next day. And each column contains 4 of the same unix time.

      Alan Kilborn 1 Reply Last reply Reply Quote 0
      • Alan Kilborn
        Alan Kilborn @Levente Horváth last edited by

        @Levente-Horváth

        I may not be realistically possible without programming, but your description cries out for posting a short sample of the data as well…

        Levente Horváth 1 Reply Last reply Reply Quote 0
        • Levente Horváth
          Levente Horváth @Alan Kilborn last edited by Levente Horváth

          @Alan-Kilborn There are thousand of timestamps like this and want to change them to the current day always.

            "timestamp": 1588464027,
          
          
          
          
          },
          {
             
            "timestamp": 1588464027,
          
          
          
          },
          {
          
            "timestamp": 1588464027,
          
          
          
          },
          {
          
            "timestamp": 1588464027,
          
          
          
          
          },
          {
             
            "timestamp": 1588464052,
          
          
          
          
          },
          {
             
            "timestamp": 1588464052,
          
          
          
          },
          {
          
            "timestamp": 1588464052,
          
          
          
          },
          {
          
            "timestamp": 1588464052,
          
          Ekopalypse 1 Reply Last reply Reply Quote 0
          • Ekopalypse
            Ekopalypse @Levente Horváth last edited by

            @Levente-Horváth

            What comes immediately to my mind are questions like

            Current day but keeping time?
            Current day and current time?
            Current day and fixed other time?

            Levente Horváth 1 Reply Last reply Reply Quote 0
            • Levente Horváth
              Levente Horváth @Ekopalypse last edited by

              @Ekopalypse These are I believe times from 05. 03. 02:00 to 04:32. I want to change them to 05. 04. 02:00 to 04:32. I don’t need a program or anything just how can I do them manually? They increment in 25.

              Ekopalypse 1 Reply Last reply Reply Quote 0
              • Ekopalypse
                Ekopalypse @Levente Horváth last edited by Ekopalypse

                @Levente-Horváth

                those timestamp look like unix timestamps, if this is the case then you can simply add 86400 seconds to it.

                Levente Horváth 1 Reply Last reply Reply Quote 3
                • Levente Horváth
                  Levente Horváth @Ekopalypse last edited by

                  @Ekopalypse How can I highlight all of them, there are 1500 timestamps, 4 of each and they are similar til 1588. But I’m an idiot of not thinking adding 86400, this was a big help already and gave me some ideas.

                  Ekopalypse 1 Reply Last reply Reply Quote 0
                  • Ekopalypse
                    Ekopalypse @Levente Horváth last edited by Ekopalypse

                    @Levente-Horváth

                    If you only want to highlight them then use
                    find dialog, goto mark tab, use the following regex \d{10}
                    check regular expression in search mode and press mark all

                    Levente Horváth 1 Reply Last reply Reply Quote 1
                    • Levente Horváth
                      Levente Horváth @Ekopalypse last edited by

                      @Ekopalypse This is great, and how can I add 86400 to all of them? :')

                      Ekopalypse 1 Reply Last reply Reply Quote 0
                      • Ekopalypse
                        Ekopalypse @Levente Horváth last edited by

                        @Levente-Horváth

                        because you said

                        I don’t need a program or anything just how can I do them manually?

                        the obvious answer would be by typing in the sum of the existing value
                        and 86400 but I get the impression that you want to do something
                        slightly different. I assume you want to select all timestamp
                        instances and then automatically add 86400 to them, correct?
                        If so, then you need some kind of script/program. If not, then
                        I still haven’t understood how you want to change these timestamps.

                        Levente Horváth 1 Reply Last reply Reply Quote 3
                        • Levente Horváth
                          Levente Horváth @Ekopalypse last edited by Levente Horváth

                          @Ekopalypse Yes that’s correct, I thought it would be easy, now I have every timestamp selected and I thought with the replace or Column Editor I can add 86400 to all of them.

                          Levente Horváth 1 Reply Last reply Reply Quote 0
                          • Levente Horváth
                            Levente Horváth @Levente Horváth last edited by

                            @Levente-Horváth What if I do Find What: \d{10}, and Replace With: \d{10}+86400

                            Ekopalypse Alan Kilborn 2 Replies Last reply Reply Quote 0
                            • Ekopalypse
                              Ekopalypse @Levente Horváth last edited by Ekopalypse

                              @Levente-Horváth

                              No, you do not have it selected, you just highlighted it, this is different and no, regex is not a calculator.
                              If you have to do such things more often then I would recommend to
                              install one of the scripting plugins like PythonScript, LuaScript and create
                              a little script to do this for you.
                              If you want to go that way we certainly can give you help solving this.

                              Levente Horváth 1 Reply Last reply Reply Quote 3
                              • Alan Kilborn
                                Alan Kilborn @Levente Horváth last edited by

                                @Levente-Horváth said in How to replace intrementally?:

                                Replace With: \d{10}+86400

                                I thought @Ekopalypse makes it clear above that things DO NOT work that way.

                                1 Reply Last reply Reply Quote 1
                                • Levente Horváth
                                  Levente Horváth @Ekopalypse last edited by Levente Horváth

                                  @Ekopalypse Then I will do it that way, whatever it takes.

                                  1 Reply Last reply Reply Quote 1
                                  • Ekopalypse
                                    Ekopalypse last edited by

                                    So you are going to install, e.g. PythonScript plugin via the plugin admin?
                                    If yes, what should the script do? Just add one day aka 86400 seconds?
                                    Or more flexible like you’ve been asked to enter the seconds you want to add?

                                    Levente Horváth 1 Reply Last reply Reply Quote 0
                                    • Levente Horváth
                                      Levente Horváth @Ekopalypse last edited by

                                      @Ekopalypse I just want to add 86400 to the existing numbers.

                                      1 Reply Last reply Reply Quote 0
                                      • Ekopalypse
                                        Ekopalypse last edited by

                                        ok, once you installed PythonScript, goto plugins->Python Script->New Script
                                        give it a meaningful name and save it.
                                        Paste the following into the newly create document and save it.

                                        from Npp import editor
                                        
                                        def add_a_day(m):
                                            return int(m.group(0)) + 86400
                                        
                                        editor.rereplace('\d{10}', add_a_day)
                                        

                                        Goto to plugin->Python Script->Scripts and execute your newly created script.

                                        If you want to add it to the toolbar play with the configuration menu of pythonscript.

                                        Alan Kilborn 1 Reply Last reply Reply Quote 4
                                        • Alan Kilborn
                                          Alan Kilborn @Ekopalypse last edited by

                                          @Ekopalypse said in How to replace intrementally?:

                                          editor.rereplace(‘\d{10}’, add_a_day)

                                          Perhaps the OP’s data contains other 10 digit numbers, not related to timestamps??

                                          I might go with this instead:

                                          editor.rereplace('"timestamp": \K\d{10}', add_a_day)

                                          Ensures that we are only changing the timestamp values.

                                          Levente Horváth 1 Reply Last reply Reply Quote 3
                                          • Levente Horváth
                                            Levente Horváth @Alan Kilborn last edited by

                                            @Alan-Kilborn No, it doesn’t contain any other 10 digit number, but I thank all of you, it works!

                                            1 Reply Last reply Reply Quote 2
                                            • First post
                                              Last post
                                            Copyright © 2014 NodeBB Forums | Contributors