Community
    • Login

    Remove every row with a number less than 1000 up to the first delimiter

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    17 Posts 7 Posters 4.1k 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.
    • Eric TilleyE
      Eric Tilley
      last edited by

      Fellow Notepad++ Users,

      Could you please help me the the following search-and-replace problem I am having?

      Im trying to remove every row with a number less than 1000 up to the first delimiter
      Here is the data I currently have (“before” data):

      2005,13952208.7138,3005327.6046,211.0373,41
      2004,13952182.3036,3005321.1366,210.3776,41
      2003,13952132.7067,3005319.3897,210.9358,41
      2002,13952126.5910,3005463.4490,211.1744,41
      2001,13952173.2366,3005468.4675,211.4982,41
      2000,13952182.4704,3005470.2489,211.7248,41
      4011,13952125.3747,3005474.5996,211.2435,4
      4010,13952192.4394,3005355.2999,211.4034,78
      4009,13952208.8454,3005327.5331,212.6928,41
      4008,13952182.3537,3005321.1124,211.9289,41
      4007,13952132.6267,3005319.3177,210.9982,41
      4006,13952142.8187,3005349.7131,211.4690,78
      4005,13952132.9044,3005437.9728,212.8579,78
      4004,13952126.5350,3005463.4456,212.3265,41
      4003,13952182.5024,3005443.5888,212.6991,78
      4002,13952173.0686,3005468.4372,211.8452,41
      4001,13952182.5687,3005470.1266,211.9242,41
      4000,13952182.4017,3005481.4235,211.0392,4
      100,13952239.6411,3005482.5839,211.9542,
      101,13952274.4338,3005343.8549,211.9542,
      102,13952208.8864,3005327.6915,211.9542,
      103,13952182.2992,3005321.1353,211.9542,
      104,13952132.6838,3005319.3749,211.9542,
      105,13952076.4358,3005317.3793,211.9542,
      106,13952054.2473,3005321.2761,211.9542,
      107,13952070.6954,3005465.4825,211.9542,
      108,13952126.6220,3005463.4814,211.9542,
      109,13952173.2139,3005468.4939,211.9542,
      110,13952182.5694,3005470.2213,211.9542,
      111,13952172.5954,3005519.1756,211.9542,
      112,13952164.6414,3005517.7536,211.9542,
      113,13952082.8906,3005514.4856,211.9542,
      200,13952182.4824,3005443.6130,211.9542,
      201,13952192.4560,3005355.2994,211.9542,
      202,13952142.8547,3005349.6977,211.9542,
      203,13952132.8811,3005438.0113,211.9542,
      
      Here is how I would like that data to look (“after” data):
      

      2005,13952208.7138,3005327.6046,211.0373,41
      2004,13952182.3036,3005321.1366,210.3776,41
      2003,13952132.7067,3005319.3897,210.9358,41
      2002,13952126.5910,3005463.4490,211.1744,41
      2001,13952173.2366,3005468.4675,211.4982,41
      2000,13952182.4704,3005470.2489,211.7248,41
      4011,13952125.3747,3005474.5996,211.2435,4
      4010,13952192.4394,3005355.2999,211.4034,78
      4009,13952208.8454,3005327.5331,212.6928,41
      4008,13952182.3537,3005321.1124,211.9289,41
      4007,13952132.6267,3005319.3177,210.9982,41
      4006,13952142.8187,3005349.7131,211.4690,78
      4005,13952132.9044,3005437.9728,212.8579,78
      4004,13952126.5350,3005463.4456,212.3265,41
      4003,13952182.5024,3005443.5888,212.6991,78
      4002,13952173.0686,3005468.4372,211.8452,41
      4001,13952182.5687,3005470.1266,211.9242,41
      4000,13952182.4017,3005481.4235,211.0392,4

      To accomplish this, I have tried using the following Find/Replace expressions and settings

      Find What = [1-999]+
      Replace With =
      Search Mode = EXTENDED
      Ive tried a couple different ways with no results. Im not sure how to make it stop at the delimiter.

      Unfortunately, this did not produce the output I desired, and I’m not sure why. Could you please help me understand what went wrong and help me find the solution?

      Thank you.

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

        @Eric-Tilley said in Remove every row with a number less than 1000 up to the first delimiter:

        Im trying to remove every row with a number less than 1000 up to the first delimiter

        I cans see there is now a small change to your request. It now appears you are ONLY wanting to test the first number, correct?

        Thanks for inserting examples inside the black box, it makes it far easier for us (helping) to copy and use that in our testing phase before supplying a solution.

        You will see I have linked your old post here. this is helpful for any readers who follow later on so they can understand the processes that went on.

        Terry

        1 Reply Last reply Reply Quote 0
        • Eric TilleyE
          Eric Tilley
          last edited by

          Yes, only the first numbers up to the first delimiter.

          1 Reply Last reply Reply Quote 0
          • Terry RT
            Terry R
            last edited by

            @Eric-Tilley said in Remove every row with a number less than 1000 up to the first delimiter:

            Im trying to remove every row with a number less than 1000 up to the first delimiter

            I have gone with the method of “marking” the rows to be removed. The benefit of this is that you can see which ones are “marked” before taking the step to remove them. This is beneficial if concerned that the wrong rows are being deleted.

            So using the “Mark” function we have
            Find What:(?-s)^(\d){1,3}(?!\d)
            Make sure “bookmark line” is ticked AND “regular expression” (under search mode) is also ticked.
            Click on “Mark All” and you will see every row with the first number below 1000 will have a blue circle in the left margin. Pressing “F2” or “Shift-F2” allows you to move forwards (or backwards) through the marked lines. Once you are happy that the marking is correct click on “Remove Bookmarked Lines” which is under Search, Bookmark, that removes those rows.

            Terry

            Alan KilbornA 1 Reply Last reply Reply Quote 2
            • Eric TilleyE
              Eric Tilley
              last edited by

              That worked great! Thank you so much.

              1 Reply Last reply Reply Quote 2
              • Alan KilbornA
                Alan Kilborn @Terry R
                last edited by Alan Kilborn

                @Terry-R said in Remove every row with a number less than 1000 up to the first delimiter:

                …happy that the marking is correct click on “Remove Bookmarked Lines” which is under Search, Bookmark, that removes those rows.

                A quicker way to get this menu to appear is to click in the margin that contains the purple ball bookmarks, like so after the right-click:

                2fcbf35e-52b1-488d-b42d-c234d054ce43-image.png

                Note the right-click point was after the 9 of line 9, directly between the two bookmark symbols. If you squint you can see that this margin is a slightly different shade of grey than the line number margin.

                Terry RT 1 Reply Last reply Reply Quote 2
                • Terry RT
                  Terry R
                  last edited by Terry R

                  @Eric-Tilley said in Remove every row with a number less than 1000 up to the first delimiter:

                  Unfortunately, this did not produce the output I desired, and I’m not sure why. Could you please help me understand what went wrong

                  I had a look at your solution and realised you made the mistake of using “meta-characters” where they don’t apply. I suggest reading the online manual for allowed “extended search” characters here. The [ and ] mean exactly that in extended mode, when used in “regular expression” mode they refer to a set that is contained within. And there was your second problem, each of the characters except for the - are tested individually. So in essence your set was numbers 1-9 (usually use 0-9), the 2 extra 9’s following were just a duplication of the preceding 9.

                  So your expression said find as many numbers which are using ONLY 1-9 (excludes the 0) together. See my example below to see what results in. The same result occurs when using [1-9]+.

                  b1164fa0-ee4a-4f97-b0d6-4b40faeb0da1-image.png

                  I think you will find a mine of information if you go through the FAQ section of this forum. Specifically the regular expression detail in the post here.

                  Good on you for trying, we like to see someone who has at least attempted to find a solution before asking here. Many however think we are a free bus service, hop-on and off at will, and seem reluctant to learn anything.

                  Terry

                  1 Reply Last reply Reply Quote 3
                  • Terry RT
                    Terry R @Alan Kilborn
                    last edited by

                    @Alan-Kilborn said in Remove every row with a number less than 1000 up to the first delimiter:

                    the purple ball bookmarks

                    You say purple, I say blue!

                    Who is right? Of course if we get a “female” to intercede it’s likely to be “deep-sea-blue”, or “sky-purple”. Most men deal in 16 colours. Those old enough would remmebr the good old days when Windows 1.x provided 16 colour renditions of the GUI, WOW!

                    cheers Alan ;-}}
                    Terry

                    PeterJonesP Alan KilbornA Neil SchipperN 3 Replies Last reply Reply Quote 1
                    • PeterJonesP
                      PeterJones @Terry R
                      last edited by

                      @Terry-R

                      Purple

                      Blue!

                      Neither!

                      RGB(25 66 191) at the dark edge
                      RGB(141 159 226) at the bright spot

                      ;-)

                      1 Reply Last reply Reply Quote 3
                      • Alan KilbornA
                        Alan Kilborn @Terry R
                        last edited by

                        @Terry-R said in Remove every row with a number less than 1000 up to the first delimiter:

                        You say purple, I say blue!
                        Who is right?

                        Well… the color of the ball (or is it a circle or a sphere, Terry? :-) ) is not uniform throughout its area, so I’m sure we’re both right and there are some definite blue pixels and some definite purple pixels – I’m not going to examine pixels but “blue” or “purple” might be arbitrated by comparison with website data that gives colors a name. Don’t laugh, colors get the scientific treatment just like everything else.

                        1 Reply Last reply Reply Quote 2
                        • guy038G
                          guy038
                          last edited by

                          Hello, @eric-tilley, @terry-r, @peterjones, @alan-kilborn and All,

                          A bit, off topic but …

                          From this site :

                          http://mkweb.bcgsc.ca/colornames/color.names.txt

                          containing a list of 9,284 colors, taken from many sources ( Color-hexa, Crayola, Pantone, Resene, rgb.txt, Wikipedia, xkcd and few others ) and with the help of some regexes, I was able to determine that the colors provided by Peter, relative to the bookmark indicator, are quite similar to the two colors below :

                          Dark edge of boomarks ( from Peter)           |  025  066  191
                          
                                 |  Index 6603  |  persian_blue         |  028  057  187  |  #1C39BB  |
                          
                          Bright spot of bookmarks ( from Peter )       |  141  159  226
                          
                                 |  Index 5194  |  light_sapphire_blue  |  139  162  231  |  #8BA2E7  |
                          

                          In your browser, press Ctrl + F to perform a search and enter the index numbers 6603 and 5194, followed with a space char => You should move to the corresponding color. Of course, all these color’s names seem quite subjective, excepted the well-known main colors !

                          In my opinion, the N++ bookmark’s color seems more blue than purple or even turquoise, as suggested by the two names persian_blue and light_sapphire_blue ;-)

                          Anyway, don’t forget that, on average, 8.3 % of the mondial population is color blind, so… !

                          Best regards,

                          guy038

                          Alan KilbornA artie-finkelsteinA 2 Replies Last reply Reply Quote 4
                          • Alan KilbornA
                            Alan Kilborn @guy038
                            last edited by

                            Somehow I just knew that @guy038 was going to weigh in on the topic of colors… :-)

                            1 Reply Last reply Reply Quote 2
                            • Terry RT
                              Terry R
                              last edited by

                              @Alan-Kilborn said in Remove every row with a number less than 1000 up to the first delimiter:

                              Somehow I just knew that @guy038 was going to weigh in on the topic of colors… :-)

                              I’m not knocking it, he’s just backed me up! BLUE wins! So Alan, now you HAVE to say blue circle/ball/sphere.

                              Cheers @guy038
                              Terry

                              1 Reply Last reply Reply Quote 1
                              • artie-finkelsteinA
                                artie-finkelstein @guy038
                                last edited by

                                When an ‘authoritative source’ ( @guy038 ) refers to another ‘authoritative source’ that in turn refers to xkcd as a source; you know that’s a well researched response. <grin> Guy, thank you, you made my day. And to top it all off, color.names.txt is a pretty cool reference to have on hand.

                                trigger warning: potential to confuse attempted humorous sarcasm with garden variety snark—
                                Note: I may have to take back some of my praise after I finally crawl back out of the seemingly bottomless hole of fascinating and unique information referenced on Mr. Krzywinski’s web site. Oh, the dangers of wandering outside one’s silo; education may be possible.

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

                                  @Terry-R said in Remove every row with a number less than 1000 up to the first delimiter:

                                  Of course if we get a “female” to intercede it’s likely to be “deep-sea-blue”, or “sky-purple”. Most men deal in 16 colours.

                                  @guy038 said in Remove every row with a number less than 1000 up to the first delimiter:

                                  don’t forget that, on average, 8.3 % of the mondial population is color blind, so… !

                                  Internet tells me:

                                  Color blindness (color vision deficiency, or CVD) affects approximately 1 in 12 men (8%) and 1 in 200 women in the world

                                  So a random pair of women, compared to a random pair of men, are more than 10x likely to agree with obervations like “color X differs from color Y” in many cases. It makes sense that among women, more fine-grained descriptive terms would emerge that are sensible to them.

                                  This is a nice instance of: “what was once a cultural trope is now a scientifically validated claim”.

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

                                    @Neil-Schipper said in Remove every row with a number less than 1000 up to the first delimiter:

                                    are more than 10x likely to agree

                                    That’s ridiculous, you.

                                    are less then a tenth as likely to disagree

                                    Better.

                                    1 Reply Last reply Reply Quote 1
                                    • guy038G
                                      guy038
                                      last edited by

                                      Hello @neil-schipper,

                                      You quoted :

                                      Color blindness (color vision deficiency, or CVD) affects approximately 1 in 12 men (8%) and 1 in 200 women in the world

                                      So my proportion of 8.3 % was not correct. Giving your statement, this leads to a real proportion of 50 % × 1 ÷ 12 + 50 % × 1 ÷ 200. So the proportion of color-blind people, among the world population, is rather ≈ 4.4 %, with a clear proportion in men compared to women ( about 16 times more ! )

                                      BR

                                      guy038

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