Community
    • Login

    How to delete ‘placeholder lines’ from a log file

    Scheduled Pinned Locked Moved General Discussion
    15 Posts 6 Posters 888 Views
    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.
    • Neil SchipperN
      Neil Schipper @guy038
      last edited by Neil Schipper

      @guy038 said in I don't understand the command line syntax to accomplish this:

      as it does not depend on the location of each column

      My first spec + expression did not depend on location!

      Here’s another likely workable spec for ID’ing lines that should be removed:

      <start of line><bunch of non-space chars><literal ‘+’><one space><anything><newline sequence>

      Advantage of this one is eyeballs don’t have to stray far from the left.

      1 Reply Last reply Reply Quote 2
      • Terry RT
        Terry R @K.M. Richards
        last edited by

        @K-M-Richards said in I don't understand the command line syntax to accomplish this:

        What I am hoping for is a solution that will accomplish this and let me learn more about doing this sort of thing in the future.

        If you look at all of the proposed solutions, you will see a common theme, one of using regular expressions. The limitation you were having was due to looking for static text which wasn’t unique to just those lines you needed to remove and possibly also using the “normal” mode of searching.

        So as you found; looking for static text; it is very hard to account for variability of content, that’s where regular expressions (called regex for short) come in handy. To learn more about regex, look in our FAQ section for a post titled “Where to find REGular EXpressions (RegEx) documentation ?”. Consider taking some lessons from those links. If you do, remember to start simply first. Regex has a lot to offer, but in the same way as building a house, it all starts with a good foundation, so understanding the basics will be helpful.

        After looking more closely at your very well structured data I can see there seems to be an alternative using static text, one that @Guy038 alluded to in his regex. So you could keep the search mode as “normal” and in the find window enter:
        AUDIO 00:00 I have 4 spaces at the start and another 4 between the AUDIO and the time. From your sample it does seem that this portion of the line is unique to ONLY those lines you wish to remove. If so, then it may be sufficient for you.

        So, although I have now provided a “normal” mode search solution, hopefully you may have also tried one or more of the regex solutions and have had your eyes opened to the possibilities of regex. As you said, “…and let me learn more about doing this sort of thing in the future.”.

        If you do start learning and get stuck, remember the forum members are only a post away. We are only too keen to help someone on their Notepad++ journey!

        Terry

        Neil SchipperN 1 Reply Last reply Reply Quote 4
        • guy038G
          guy038
          last edited by

          Hi, @k-m-richards, @terry-r, @neil-schipper and All,

          @neil-schipper : I completely apologize about my previous statement :

          Here is , to my mind, a nice solution, as it does not depend on the location of each column, supposing the same layout, of course !

          Indeed, In my previous post, I just searched for a solution which could work without any specification on the exact location of each column, forgetting to try your own regexes . And, indeed, your first ( \h+\d{1,2}:\d\d\h+\w ) and second regex ( ^.*?\h+\d{1,2}:\d\d\h+\w.*?\R ) do respect this condition !

          Well, in general, I try, at first, to think about a new problem without referring to other solutions already proposed. This is both to get a “fresh” look at the problem and to find my own solution.

          However, very often, I end up with ways of doing things and expressions that turn out to be too sophisticated and lead me to think that the solutions already mentioned are the best ones !!

          Best Regards

          guy038

          1 Reply Last reply Reply Quote 2
          • Neil SchipperN
            Neil Schipper @Terry R
            last edited by Neil Schipper

            @Terry-R

            I can see … an alternative using static text … So you could keep the search mode as “normal”

            This is true, and interesting, but in this case it only supports a multi-step (bookmark-and-delete) workflow, but not a single step ReplAll.

            @guy038

            Well, in general, I try, at first, to think about a new problem without referring to other solutions … both to get a “fresh” look at the problem and to find my own solution.

            I do that too, a good practice.

            @k-m-richards

            A small corrective: “command line syntax” applies to command line interfaces (most famously the DOS or Windows console CLI’s, but there are many others); “search expression syntax” is what we’ve been using here.

            Terry RT 1 Reply Last reply Reply Quote 1
            • Terry RT
              Terry R @Neil Schipper
              last edited by

              @Neil-Schipper said in I don't understand the command line syntax to accomplish this:

              This is true, and interesting, but in this case it only supports a multi-step (bookmark-and-delete) workflow, but not a single step ReplAll.

              And that’s what the OP was doing, using (Book)mark to find those lines. Of course, if he wasn’t aware, he will be now through these series of posts that he can achieve it all in 1 step.

              However when I was first learning regex I used the bookmark and find functions quite a bit to understand the boundaries of my regex, to get a feel for how different “formulae” would work on data, I probably still do to be honest. I think it is a valuable tool in the learning process. Even if it does take multiple steps, it’s still far quicker then manually marking each line.

              Terry

              Neil SchipperN 1 Reply Last reply Reply Quote 4
              • Neil SchipperN
                Neil Schipper @Terry R
                last edited by

                @Terry-R said in I don't understand the command line syntax to accomplish this:

                … I used the bookmark and find functions quite a bit to understand the boundaries of my regex … I probably still do to be honest.

                Interesting how our histories differ. I use bookmarks mainly for navigation and am hesitant to perform operations that would pollute the list, or blow them all away, and, I use find-match-mark to colorize, but I don’t think I’ve ever used find-match-bookmark to solve a practical problem of my own, and consider it an oddity.

                K.M. RichardsK 1 Reply Last reply Reply Quote 2
                • K.M. RichardsK
                  K.M. Richards @Neil Schipper
                  last edited by

                  Thank you all for your detailed suggestions and explanations of how they would work.

                  I am going to print out this entire thread and read it over several times and then experiment some more. It looks to me that the solution that will work best for me is somewhere in there!

                  It is also gratifying that there are still places where if you ask politely for help, you receive it with equal measures of politeness. You are all very nice people for trying to help.

                  PeterJonesP 1 Reply Last reply Reply Quote 1
                  • PeterJonesP
                    PeterJones @K.M. Richards
                    last edited by PeterJones

                    @K-M-Richards ,

                    With the topic named “I don’t understand the command line syntax to accomplish this”: as future readers come browsing or searching through old forum posts, they will have no clue what it’s about. And even if you come back some time later, reading through your old topic titles, you might not know what question you were asking originally.

                    Would you mind if I used admin powers to rename your topic to “how to delete ‘placeholder lines’ from a log file” ?

                    K.M. RichardsK 1 Reply Last reply Reply Quote 1
                    • K.M. RichardsK
                      K.M. Richards @PeterJones
                      last edited by

                      @PeterJones By all means, if you think it will help others with similar difficulties.

                      K.M. RichardsK 1 Reply Last reply Reply Quote 2
                      • K.M. RichardsK
                        K.M. Richards @K.M. Richards
                        last edited by

                        I just wanted to come back and thank everyone again for their help. As I had hoped, I took parts of multiple suggestions and came up with a sequence of search-and-replace steps which has reduced my log editing time to under ten minutes for a full week’s worth. Two months into the new process and not a single glitch!

                        Best of all, I increased my knowledge base in the process. I love it when solving a problem results in my learning something new!

                        Again, thank you all for your help.

                        1 Reply Last reply Reply Quote 4
                        • Zahid MehmoodZ
                          Zahid Mehmood
                          last edited by

                          This post is deleted!
                          1 Reply Last reply Reply Quote -1
                          • First post
                            Last post
                          The Community of users of the Notepad++ text editor.
                          Powered by NodeBB | Contributors