Community
    • Login

    Need to extract specific info from text file

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    10 Posts 4 Posters 1.3k 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.
    • yosharianY
      yosharian
      last edited by

      Hi I have a text file which has entries like the following:

      new entry “MAG_CQCaster_ArcaneChargeAfterDash_Boots”
      type “Armor”
      using “_Foot_Magic”
      data “RootTemplate” “400b3aca-fc9e-44c7-b5a7-a183693d3a75”
      data “ValueUUID” “a229f048-70b0-4b0c-88cb-29b5c6bdb2d0”
      data “Rarity” “Rare”
      data “PassivesOnEquip” “MAG_CQCaster_ArcaneChargeAfterDash_Boots_Passive”
      data “MinAmount” “1”
      data “MaxAmount” “1”
      data “Priority” “1”
      data “Unique” “1”
      data “MinLevel” “1”

      I want to extract only the NEW ENTRY data and the ROOTTEMPLATE data, and specifically the data itself.

      So for example, for this entry I want:

      MAG_CQCaster_ArcaneChargeAfterDash_Boots
      400b3aca-fc9e-44c7-b5a7-a183693d3a75

      Is there a way to extract only this data from each entry, automatically?

      Bear in mind I am not a coder so I would need pretty basic instructions.

      Would really appreciate any help.

      Terry RT Alexander VerbitskyA 3 Replies Last reply Reply Quote 0
      • Terry RT
        Terry R @yosharian
        last edited by Terry R

        @yosharian
        If the data you want is on 1 line you can use the Find Mark option, ticking the option called bookmark.

        The online manual here has the reference for this. You would run it with the different text you want to look for. For each run the line would have a bookmark symbol created in the left margin.

        After bookmarking, you can copy those bookmarked lines to another tab.

        Terry

        yosharianY 1 Reply Last reply Reply Quote 1
        • yosharianY
          yosharian @Terry R
          last edited by

          @Terry-R I’m sorry I don’t understand…

          Terry RT Alan KilbornA 2 Replies Last reply Reply Quote 0
          • Terry RT
            Terry R @yosharian
            last edited by

            @yosharian
            Have you read the reference?

            Also search for posts here using the word bookmark.

            Terry

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

              @yosharian

              Something like this might work:

              eafa529c-3e01-452c-ae3b-4eb49eaf6bbd-image.png

              After running the Mark All you can use Copy Marked Text to put the resulting text somewhere else.

              Find what expression as text: ^(new entry|data “RootTemplate”) “\K.+?(?=”)

              You didn’t follow posting rules so maybe you don’t have smart double quotes, in which case the needed Find what expression as text is possibly: ^(new entry|data "RootTemplate") "\K.+?(?=")

              If you’re curious about the posting rules, see HERE.

              1 Reply Last reply Reply Quote 1
              • Alexander VerbitskyA
                Alexander Verbitsky @yosharian
                last edited by

                @yosharian Can you add a sample with both data you want and data you don’t? It is possible to write regexps to

                1. Delete unwanted data
                2. Transform remaining useful data
                1 Reply Last reply Reply Quote 0
                • Alexander VerbitskyA
                  Alexander Verbitsky @yosharian
                  last edited by

                  @yosharian For example, assuming you use Windows line endings (\r\n) and use double quotes instead of smart quotes this regexp

                  new entry.*"(.*)"\r\n(?:(?:(?:type.*)|(?:using.*))\r\n)*(?:(?:data.*RootTemplate.* "(.*)"\r\n)|(?:data.*\r\n))*
                  

                  extracts data you need with “Find and replace” tool.
                  Снимок экрана 2023-08-07 181649.png

                  Alan KilbornA 1 Reply Last reply Reply Quote 0
                  • Alan KilbornA
                    Alan Kilborn @Alexander Verbitsky
                    last edited by Alan Kilborn

                    @Alexander-Verbitsky said in Need to extract specific info from text file:

                    new entry."(.)“\r\n(?:(?:(?:type.)|(?:using.))\r\n)(?:(?:data.RootTemplate. "(.)”\r\n)|(?:data.\r\n))

                    Why are you providing this much-more-complicated solution, when a simpler solution has been given above?
                    And…OP hasn’t poo-poo’d the earlier solution…
                    And…OP hasn’t answered your previous question yet…

                    Alexander VerbitskyA 1 Reply Last reply Reply Quote 0
                    • Alexander VerbitskyA
                      Alexander Verbitsky @Alan Kilborn
                      last edited by

                      @Alan-Kilborn My solution transforms text as OP wants. OK, I don’t know, maybe marking text suits his need.

                      Alan KilbornA 1 Reply Last reply Reply Quote 0
                      • Alan KilbornA
                        Alan Kilborn @Alexander Verbitsky
                        last edited by

                        @Alexander-Verbitsky said in Need to extract specific info from text file:

                        My solution transforms text as OP wants. OK, I don’t know, maybe marking text suits his need.

                        All OP said was “extract”, not “transform”.

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