Search for a list of strings in another file.
-
- 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?
-
This post is deleted! -
@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.
Terry
-
@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).
-
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 filefile2.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
andFile2.txt
? -
Could you tell us, the approximative number of lines of your two files
File1.txt
andFile2.txt
?
Best Regards
guy038
-
-
@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
-
@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. -
@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