• Login
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.
  • Y
    yosharian
    last edited by Aug 7, 2023, 7:29 AM

    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.

    T A 3 Replies Last reply Aug 7, 2023, 7:48 AM Reply Quote 0
    • T
      Terry R @yosharian
      last edited by Terry R Aug 7, 2023, 8:21 AM Aug 7, 2023, 7:48 AM

      @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

      Y 1 Reply Last reply Aug 7, 2023, 8:05 AM Reply Quote 1
      • Y
        yosharian @Terry R
        last edited by Aug 7, 2023, 8:05 AM

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

        T A 2 Replies Last reply Aug 7, 2023, 8:10 AM Reply Quote 0
        • T
          Terry R @yosharian
          last edited by Aug 7, 2023, 8:10 AM

          @yosharian
          Have you read the reference?

          Also search for posts here using the word bookmark.

          Terry

          1 Reply Last reply Reply Quote 0
          • A
            Alan Kilborn @yosharian
            last edited by Alan Kilborn Aug 7, 2023, 10:55 AM Aug 7, 2023, 10:54 AM

            @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
            • A
              Alexander Verbitsky @yosharian
              last edited by Aug 7, 2023, 3:02 PM

              @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
              • A
                Alexander Verbitsky @yosharian
                last edited by Aug 7, 2023, 3:17 PM

                @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

                A 1 Reply Last reply Aug 7, 2023, 3:19 PM Reply Quote 0
                • A
                  Alan Kilborn @Alexander Verbitsky
                  last edited by Alan Kilborn Aug 7, 2023, 3:20 PM Aug 7, 2023, 3:19 PM

                  @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…

                  A 1 Reply Last reply Aug 7, 2023, 3:26 PM Reply Quote 0
                  • A
                    Alexander Verbitsky @Alan Kilborn
                    last edited by Aug 7, 2023, 3:26 PM

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

                    A 1 Reply Last reply Aug 7, 2023, 4:12 PM Reply Quote 0
                    • A
                      Alan Kilborn @Alexander Verbitsky
                      last edited by Aug 7, 2023, 4:12 PM

                      @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
                      2 out of 10
                      • First post
                        2/10
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors