Community

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

    Sperate Columns From Single String

    Help wanted · · · – – – · · ·
    4
    10
    87
    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.
    • Jack Patil
      Jack Patil last edited by Jack Patil

      Source Data

      Cust_Id,Cust_Name,Cust_Address,Cust_Salary
      1,Name1,Address,12,Road,40,10000
      2,Name2,Address,3,20,20000
      

      Desired Output

      Cust_Id|Cust_Name|Cust_Address|Cust_Salary
      1|Name1|Address,12,Road,40|10000
      2|Name2|Address,3,20|20000
      

      I want to Separate Data Column Wise and Instead of Comma I want Pipe Delimiter, How to do that in Notepad++

      dinkumoil 1 Reply Last reply Reply Quote 1
      • dinkumoil
        dinkumoil @Jack Patil last edited by dinkumoil

        @Jack-Patil

        04ddb9c7-1f54-4580-a7f6-63a373382cb9-grafik.png

        Provided that the Cust_Name column contains no (comma-separated) multi-part content:

        Find what: ^(.+?),(.+?),(.+),(.+?)$
        Replace with: $1\|$2\|$3\|$4

        Jack Patil 1 Reply Last reply Reply Quote 5
        • Jack Patil
          Jack Patil @dinkumoil last edited by

          @dinkumoil Thanx a Lot it’s Working Perfectly.

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

            @dinkumoil 's solution works great.

            Just a note to say that | is not a “special character” when used in the Replace with part of a regular expression. Thus it does not need to be “escaped” with \.

            In other words, this would have worked just as well for the Replace with:

            $1|$2|$3|$4

            dinkumoil 1 Reply Last reply Reply Quote 4
            • guy038
              guy038 last edited by

              Hello, @jack-patil, @dinkumoil, @alan-kilborn and All,

              An other solution could be :

              SEARCH ,(?=.*Address|Cust)|,(?=\d+$)

              REPLACE |

              BR

              guy038

              Alan Kilborn 1 Reply Last reply Reply Quote 0
              • Alan Kilborn
                Alan Kilborn @guy038 last edited by Alan Kilborn

                @guy038 said in Sperate Columns From Single String:

                ,(?=.*Address|Cust)|,(?=\d+$)

                I don’t think that will work on real data.
                I’ve got to believe that OP has used Name1, Address, etc. as mockups in the data (below the obvious “header” line at the top), to avoid publishing sensitive data?

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

                  Hello, @jack-patil, @dinkumoil, @alan-kilborn and All,

                  Yes, Alan, you’re certainly right about it ! Indeed, the strings Name1, Name2 and Address seem to be generic terms !

                  Just thought of this text, in a literally way. My bad :-((

                  BR

                  guy038

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

                    @guy038 said in Sperate Columns From Single String:

                    Just thought of this text, in a literally way.

                    No worries!
                    Not only do we have to solve problems (if we choose to reply), we also have to “play detective” to know what a poster is and isn’t saying with their descriptions, even when they put their data in a nice code block.

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

                      @Alan-Kilborn said in Sperate Columns From Single String:

                      | is not a “special character” when used in the Replace with part of a regular expression

                      Hmm, you are right. Don’t know how, but in some way I had in mind that it is required. Anyway, good to know that it is not.

                      Alan Kilborn 1 Reply Last reply Reply Quote 3
                      • Alan Kilborn
                        Alan Kilborn @dinkumoil last edited by Alan Kilborn

                        @dinkumoil said in Sperate Columns From Single String:

                        Hmm, you are right. Don’t know how, but in some way I had in mind that it is required. Anyway, good to know that it is not.

                        It really IS hard to keep all this regular expression syntax straight. :-(

                        I wasn’t pointing it out to pick apart your regular expression, though.

                        People learn new things from what they see here, even if it isn’t their question.
                        \| works…but if people can know they can write replacement expressions in Notepad++ involving | without a bunch of leaning toothpicks, then so much the better.

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