• Login
Community
  • Login

Search for a list of strings in another file.

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
8 Posts 5 Posters 3.6k 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.
  • G
    gendalv
    last edited by gendalv Mar 24, 2023, 8:06 PM Mar 24, 2023, 8:01 PM

    • For each line in file1.txt a search input for search&replace box in file2.txt is made and removes it.

    Is there a simple way to do this or a plugin?

    M T 2 Replies Last reply Mar 24, 2023, 8:33 PM Reply Quote 0
    • M
      Mark Olson @gendalv
      last edited by Mar 24, 2023, 8:33 PM

      This post is deleted!
      1 Reply Last reply Reply Quote 0
      • T
        Terry R @gendalv
        last edited by Mar 25, 2023, 2:08 AM

        @gendalv said in Search for a list of strings in another file.:

        Is there a simple way to do this or a plugin?

        This question has been put simply, but there isn’t a simple answer. It will depend on some things, not the least of which is the data. If each line that occurs in file1 is also a line in file2 then the obvious would be to combine both files, sort and delete duplicated lines. But as you have said very little about what your data. Maybe you dont want data sorted (there are methods to restore the original order).

        Perhaps read these 2 old posts which have a similar theme, come back with more information and be prepared to answer yet further questions. Please also read the pinned post Please Read This Before Posting before posting any additional information. Be aware that this and other FAQ posts are there to help you so that when you ask a question like this one you can include other information that may well be crucial in getting the correct solution provided.

        • Deleting numbers from LIST 1, that also appear in LIST 2

        • How to remove the content from file1 or list1 (e.g. 4000 usernames) from file2 or list2 (e.g. 50000 usernames)

        Terry

        G 1 Reply Last reply Mar 25, 2023, 2:23 AM Reply Quote 2
        • G
          gendalv @Terry R
          last edited by Mar 25, 2023, 2:23 AM

          @Terry-R deleting duplicated would leave the one occurrence behind for each duplicate found, it’s just merging that you’re suggesting, but I need to exclude(remove).

          T 1 Reply Last reply Mar 25, 2023, 3:13 AM Reply Quote 0
          • G
            guy038
            last edited by guy038 Mar 25, 2023, 3:09 AM Mar 25, 2023, 3:07 AM

            Hello, @gendalv, @terry-r, @mark-olson and all,

            @gendalv, if I understand you correctly :

            • You have a File1.txt file

            • For each line of File1.txt, you want to verify that a specific pattern ( may be the whole line ) also exists in a second file file2.txt

            • And, in this case, you would like to delete the corresponding line in the File2.txt file ?


            On the other hand :

            • Could you tell us, the approximative size of your two files File1.txt and File2.txt ?

            • Could you tell us, the approximative number of lines of your two files File1.txt and File2.txt ?

            Best Regards

            guy038

            1 Reply Last reply Reply Quote 0
            • T
              Terry R @gendalv
              last edited by Mar 25, 2023, 3:13 AM

              @gendalv said in Search for a list of strings in another file.:

              deleting duplicated would leave the one occurrence behind for each duplicate found

              Not necessarily. A regular expression will delete all/both copies.

              As I said, you haven’t provided much information so I’m not going to spend a lot of time explaining it in detail either.

              Terry

              G 1 Reply Last reply Mar 25, 2023, 3:19 AM Reply Quote 1
              • G
                gendalv @Terry R
                last edited by gendalv Mar 25, 2023, 3:28 AM Mar 25, 2023, 3:19 AM

                @Terry-R idk how to make compares like that with regex, seems way too complicated.

                Anyway the “usernames” link above worked, although I had to figure out how to actually run a python script in np++, ended up installing PythonScript plugin, which is also not obvious, how to add a script to, but, after some fiddling, script by Scott Sumner works.
                Although without regex in each line, but it’s better than manually doing it, just needs some prep.

                A 1 Reply Last reply Mar 25, 2023, 10:51 AM Reply Quote 0
                • A
                  Alan Kilborn @gendalv
                  last edited by Mar 25, 2023, 10:51 AM

                  @gendalv said in Search for a list of strings in another file.:

                  although I had to figure out how to actually run a python script in np++, ended up installing PythonScript plugin, which is also not obvious, how to add a script to, but, after some fiddling

                  You could have found quicker answers had you consulted this site’s FAQ entry for : How to install and run a script in PythonScript

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