Community
    • Login

    Editing a list/ Moving words

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    23 Posts 6 Posters 1.4k 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.
    • Alan KilbornA
      Alan Kilborn @Mathew888
      last edited by Alan Kilborn

      @Mathew888

      I may be going about this completely the wrong way.

      You’re (probably) thinking the correct way.

      Could I ask another question regarding this please.

      Yes, but… I’ll warn you that you can’t keep asking infinite questions here about data formatting (although 2 hardly qualifies as infinite).

      You’ll soon be told to read the documentation and figure out how to do your own transformations. Or to show us what you tried and what didn’t work.

      This is simply because this is a discussion site about Notepad++, and data transformation really isn’t a Notepad++ topic.

      And because we’ve had trouble in the past with people that don’t want to learn, don’t want to think for themselves, and just want others to provide all of their data transformation needs.

      But for now, another freebie:

      find: (?-s)^(.+)\R(.+)
      repl: ${1}\t${2}

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

        @Alan-Kilborn
        Thank you, I take on board what you’re saying.

        I was keen to know how the methods were working because I am trying to learn.
        It’s just that it’s genuinely a whole new language to me.
        I don’t know if there’s a Youtube channel suitable for beginners or something like that.

        I’ve just figured out that if I change your last to:
        find: (?-s)^(.+)\R(.+)
        repl: ${2}\t${1}

        it places the Video Length Column before the Video Name Column and that is now perfect.

        Once again thank you for your help!

        PeterJonesP Alan KilbornA 2 Replies Last reply Reply Quote 2
        • Mathew888M
          Mathew888
          last edited by

          Sorry I meant to say it places the Video Name Column before the Video Length Column and that is now perfect.

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

            @Mathew888 ,

            The best way to learn regex is to practice. Play around with data and the regexes you see posted here, and see what happens when you change either the regex or the data, and see how the matching changes; a tool like Notepad++'s Find > Mark is great for such experimentation, because it will immediately show you where the matches are, rather than making you cycle through a bunch of Find Next buttons.

            Our FAQ section has an entry on regex resources, which is a good starting place for learning regex.

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

              @Mathew888 said in Editing a list/ Moving words:

              I’ve just figured out that if I change your last to:
              find: (?-s)^(.+)\R(.+)
              repl: ${2}\t${1}
              it places the Video Length Column before the Video Name Column and that is now perfect.

              Sorry, I didn’t really notice what ordering you wanted the columns in.
              But your ability to see the pattern in how the regular expression is working, and adapt it to your need is a key step.
              Sadly, a lot of other askers in the past were not able to make that leap.

              1 Reply Last reply Reply Quote 2
              • astrosofistaA
                astrosofista @Mathew888
                last edited by

                @Mathew888 said in Editing a list/ Moving words:

                …I need to transfer this data into two columns within an Excel worksheet.

                You might not be aware of this, but if all you need to do is import the example data from your first post into Excel, you can edit it in a single step, as follows:

                Search: ^(\d+:\d+(?::\d+)?)\R(.+)\R(Subtitles)?\R?
                Replace: $2(?3 \($3\))\t$1\r\n
                

                Of course, it’s a more complex expression, but doable. Look for details and insights in the docs.

                Mathew888M 1 Reply Last reply Reply Quote 2
                • Mathew888M
                  Mathew888 @astrosofista
                  last edited by

                  @astrosofista
                  Thank you for this, I’ll give it a go.

                  Alan KilbornA Neil SchipperN 2 Replies Last reply Reply Quote 1
                  • Alan KilbornA
                    Alan Kilborn @Mathew888
                    last edited by

                    @Mathew888

                    Combining it all into one larger and more complicated expression is only really necessary if you have a need to do it over and over again. If it is just a one-time need, don’t worry about making it “efficient”.

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

                      @Mathew888 The folks helping you have deep knowledge of regex (which is a kind of programming language) and are very generous with their time.

                      Learning the basics of regex and what it can do may serve you very well down the road (not least because you will be in a position to look up complex features).

                      Nonetheless, this problem is also solved with np++ macros and no use of regex S&R. I achieved (what I take to be) your desired output:

                      Video Name A (Subtitles)	0:44
                      Video Name B (Subtitles)	11:32
                      Video Name C	10:03
                      Video Name D	0:36
                      Video Name E (Subtitles)	1:26:58
                      Video Name F	10:27
                      

                      with 2 rounds of applying macros I recorded.

                      To prepare:

                      1. In Preferences, Language, Tab Settings, normal (careful, choose what applies to you), ensure ‘Replace by space’ is not checked
                      2. In find window, set Search mode = extended, search text = \nSubtitles; do at least one search. (Satisfy yourself that ‘Find’ does what you hope.) Caret to start of file.

                      First macro finds “Subtitles” at the start of a line (F3), and then does familiar editing to get the text on the prior line and add parenthesis.

                      After checking (maybe on a small file with a handful of entries) can save the macro and run it “Multiple times”. The very last instance might muck the last entry up, fix with Ctl-z.

                      Second macro does simple editing: cut text of video duration, delete line, navigate to end of the current line (name, maybe with subtitle), insert tab, paste duration, cursor to start of next entry.

                      Run macro on the whole file, again maybe fix up last entry.

                      It can be fun developing and checking macros; there’s much less reference material to plow through. You may need to fuss about various settings before you run it (and change back afterwards to what you prefer in normal editing), and, where you leave the cursor before you stop recording.

                      Regex’s is a much deeper topic than macros, but the latter can solve lots of problems, and in a more intuitive way.

                      Mathew888M 1 Reply Last reply Reply Quote 2
                      • Mathew888M
                        Mathew888 @Neil Schipper
                        last edited by

                        @Neil-Schipper
                        Thanks for your info on Macros in this kind of situation, I’ve heard of them but have not used them previously.

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