Community
    • Login

    Extracting the Column with condition

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    14 Posts 3 Posters 827 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.
    • nicol armN
      nicol arm @Alan Kilborn
      last edited by

      @Alan-Kilborn said in Extracting the Column with condition:

      @nicol-arm

      Column with condition

      Umm, I think you left off what the condition is…and it appears you are extracting rows, not columns…??

      sorry it’s row

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @nicol arm
        last edited by Alan Kilborn

        @nicol-arm

        I repeat:

        I think you left off what the condition is

        In other words, what are the criterion for keeping version discarding a row?

        nicol armN 1 Reply Last reply Reply Quote 1
        • nicol armN
          nicol arm @Alan Kilborn
          last edited by

          @Alan-Kilborn said in Extracting the Column with condition:

          In other words, what are the criterion for keeping version discarding a row?

          Excuse me but I don’t understand, I only require the rows that start with the mail

          1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones
            last edited by

            @nicol-arm said in Extracting the Column with condition:

            I only require the rows that start with the mail

            “start with the mail” is a very unhelpful condition. Do you mean “start with certain email addresses that @nicol-arm has in mind but is asking the Community to infer from the post”? Or do you mean “start with only a valid email address, which @nicol-arm happens to assume has no colon :, so the Community should infer anything with a colon : before the @ is not a line matched”? Or something else that I cannot guess?

            If you want help, you have to provide details. The below will help you understand better; please read it!

            -----

            Please Read And Understand This

            FYI: I often add this to my response in regex threads, unless I am sure the original poster has seen it before. Here is some helpful information for finding out more about regular expressions, and for formatting posts in this forum (especially quoting data) so that we can fully understand what you’re trying to ask:

            This forum is formatted using Markdown. Fortunately, it has a formatting toolbar above the edit window, and a preview window to the right; make use of those. The </> button formats text as “code”, so that the text you format with that button will come through literally ; use that formatting for example text that you want to make sure comes through literally, no matter what characters you use in the text (otherwise, the forum might interpret your example text as Markdown, with unexpected-for-you results, giving us a bad indication of what your data really is).

            Images can be pasted directly into your post, or you can hit the image button. (For more about how to manually use Markdown in this forum, please see @Scott-Sumner’s post in the “how to markdown code on this forum” topic, and my updates near the end.) Please use the preview window on the right to confirm that your text looks right before hitting SUBMIT. If you want to clearly communicate your text data to us, you need to properly format it.

            If you have further search-and-replace (“matching”, “marking”, “bookmarking”, regular expression, “regex”) needs, study the official Notepad++ searching using regular-expressions docs, as well as this forum’s FAQ and the documentation it points to. Before asking a new regex question, understand that for future requests, many of us will expect you to show what data you have (exactly), what data you want (exactly), what regex you already tried (to show that you’re showing effort), why you thought that regex would work (to prove it wasn’t just something randomly typed), and what data you’re getting with an explanation of why that result is wrong. When you show that effort, you’ll see us bend over backward to get things working for you. If you need help formatting, see the paragraph above.

            Please note that for all regex and related queries, it is best if you are explicit about what needs to match, and what shouldn’t match, and have multiple examples of both in your example dataset. Often, what shouldn’t match helps define the regular expression as much or more than what should match.

            Here is the way I usually break down trying to figure out a regex (whether it’s for myself or for helping someone in the forum):

            1. Compare what portions of each line I want to match is identical to every other one (“constants”), and what parts do I want to allow to be different in each line (“variables”) but still be part of the match.
            1. Look at both the variables and constants, and see what portions of each I’ll want to keep or move around, vs which parts get thrown away completely. Each sub-component that I want to keep will be put in a regex group. Anything that gets completely thrown away doesn’t need to be in a group, though sometimes I put it in a numbered (___) or unnumbered (?:___) group anyway, if I have a good reason for it. Anything that needs to be split apart, I break into multiple groups, instead of having it as one group.
            1. For each group, I do a mental “how would I describe to my son how to correctly match these characters?” – which should hopefully give me a simple, foolproof algorithm of characters that must match or must not match; then I ask, “how would I translate those instructions into regex sequences?” If I don’t know the answer to the second, I read documentation, or ask a specific question.
            1. try it, debug, iterate.
            nicol armN 2 Replies Last reply Reply Quote 1
            • nicol armN
              nicol arm @PeterJones
              last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • nicol armN
                nicol arm @PeterJones
                last edited by

                @PeterJones

                Excuse me sir, I didn’t want to bother you

                Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 0
                • Alan KilbornA
                  Alan Kilborn @nicol arm
                  last edited by

                  @nicol-arm said in Extracting the Column with condition:

                  I didn’t want to bother you

                  You’re not bothering anyone, you just need to frame your problem statement so it makes sense. Otherwise, no one will be able to help you with your problem. Do you understand?

                  1 Reply Last reply Reply Quote 1
                  • PeterJonesP
                    PeterJones @nicol arm
                    last edited by PeterJones

                    @nicol-arm said in Extracting the Column with condition:

                    @PeterJones

                    Excuse me sir, I didn’t want to bother you

                    As I said before, “If you want help, you have to provide details.” I wasn’t trying to say “<wc_fields_impression>go away kid, you bother me</wc_fields_impression>”. I was trying to help you: we cannot answer you unless you give us enough information to go on. So far, no matter who asks for clarification, or how, you aren’t providing the additional details. If you want help, you will have to help us help you by answering the questions we ask.

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

                      @PeterJones

                      I guess we scare people off.
                      Pesky us, asking for some level of detail.

                      nicol armN 1 Reply Last reply Reply Quote 2
                      • nicol armN
                        nicol arm @Alan Kilborn
                        last edited by nicol arm

                        @Alan-Kilborn

                        friend these are my lines

                        rotector:lyndennelson_@hotmail.com:1402889569brotector:brotector:brotector:brotector
                        chris.vancura@me.com:1402889576:DI)d/:134A2FF5-A236-471C-944A-EA3C20018048
                        mikeyjulian@me.com:1402889601:1403494404f:E219F3E1-2669-43B7-B172-31F9AD53199D
                        azerat:fallstar@me.com:1402889686:1403509967:mazerat:mazerat:mazerat:mazerat:f0bffa36c4ad18a3893e8777fd34c936:_C5ke:6830D32C-A73A-4FD0-883B-B6962A7BC049
                        alym:djrenner@me.com:1402889716:Kalym:kalym:kalym:kalym:“”“-3GR”:6B5D3486-E305-E311-B9FB-E4115BBB7082
                        heExpectorator:jaaronhaskett@me.com:1402889752:“VulgartheStalker”:vulgar-the-stalker:“vulgarthestalker”:theexpectorato
                        galya15@me.com:1402889798:(b~p:642273FB-A46D-4DE2-B179-91CFB2D6E0EE
                        abeldom@hotmail.com:1402889835:1403494636
                        latch:queda@me.com:1402889853:flatch:flatch:flatch
                        uddlyCobra:christor@shaw.ca:1402889875:cuddlycobra:cuddlycobra:D31789B7-5A2C-4BAA-9F38-364493693131

                        I only need those rows that start with the email

                        chris.vancura@me.com:1402889576:DI)d/:134A2FF5-A236-471C-944A-EA3C20018048
                        mikeyjulian@me.com:1402889601:1403494404f:E219F3E1-2669-43B7-B172-31F9AD53199D
                        galya15@me.com:1402889798:(b~p:642273FB-A46D-4DE2-B179-91CFB2D6E0EE
                        abeldom@hotmail.com:1402889835:1403494636
                        
                        1 Reply Last reply Reply Quote 0
                        • PeterJonesP
                          PeterJones
                          last edited by PeterJones

                          @nicol-arm said in Extracting the Column with condition:

                          I only need those rows that start with the email

                          You still haven’t said how you can tell that rotector:lyndennelson_@hotmail.com isn’t a valid email. Per Wiki:Email_address,

                          space and special characters "(),:;<>@[] are allowed with restrictions (they are only allowed inside a quoted string, as described in the paragraph below, and in addition, a backslash or double-quote must be preceded by a backslash)

                          So they can be part of a valid email address; the SMTP mail system requires that they be quoted if used in the To/From… but there is no such universal/absolute requirement for all systems that store emails; if your CSV (character-separated-value: in this case, apparently colon-separated) database assumes that colons are invalid in email, there is a bug in your database design.

                          Assuming you want to perpetuate the falsehood that colons aren’t part of valid email addresses, your solution would be

                          • FIND = ^.*?:.*?\@.*(\R|\Z)
                          • REPLACE = (empty)
                          rotector:lyndennelson_@hotmail.com:1402889569brotector:brotector:brotector:brotector
                          chris.vancura@me.com:1402889576:DI)d/:134A2FF5-A236-471C-944A-EA3C20018048
                          mikeyjulian@me.com:1402889601:1403494404f:E219F3E1-2669-43B7-B172-31F9AD53199D
                          azerat:fallstar@me.com:1402889686:1403509967:mazerat:mazerat:mazerat:mazerat:f0bffa36c4ad18a3893e8777fd34c936:_C5ke:6830D32C-A73A-4FD0-883B-B6962A7BC049
                          alym:djrenner@me.com:1402889716:Kalym:kalym:kalym:kalym:"""-3GR":6B5D3486-E305-E311-B9FB-E4115BBB7082
                          heExpectorator:jaaronhaskett@me.com:1402889752:“VulgartheStalker”:vulgar-the-stalker:“vulgarthestalker”:theexpectorato
                          galya15@me.com:1402889798:(b~p:642273FB-A46D-4DE2-B179-91CFB2D6E0EE
                          abeldom@hotmail.com:1402889835:1403494636
                          latch:queda@me.com:1402889853:flatch:flatch:flatch
                          uddlyCobra:christor@shaw.ca:1402889875:cuddlycobra:cuddlycobra:D31789B7-5A2C-4BAA-9F38-364493693131
                          

                          becomes

                          chris.vancura@me.com:1402889576:DI)d/:134A2FF5-A236-471C-944A-EA3C20018048
                          mikeyjulian@me.com:1402889601:1403494404f:E219F3E1-2669-43B7-B172-31F9AD53199D
                          galya15@me.com:1402889798:(b~p:642273FB-A46D-4DE2-B179-91CFB2D6E0EE
                          abeldom@hotmail.com:1402889835:1403494636
                          

                          … which appears to be what you want, despite the error in your assumptions.

                          That regex matches any that does have a colon before the first @, and deletes the whole row. The (\R|\Z) matches either newline or the end of the file (so it will work even if the uddlyCobra line doesn’t have a newline sequence).

                          nicol armN 1 Reply Last reply Reply Quote 1
                          • nicol armN
                            nicol arm @PeterJones
                            last edited by

                            @PeterJones
                            Peter Jones, thanks a lot
                            Solved

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