How to search many conditions automatically?
-
Hi, I have two files (.txt):
1.The condition file
2.The results file
The condition contains many lines of data which I need to compare in the results and find out count of each line. I did it with ctr+f, but it`s too long and takes so many time.How can I find out, what I should do to find how many lines of the conditions have in the results and create report file (“condition” “how many matches have in numbers”) automatically?
Thx for answers
-
@Григорий-Новожилов My interpretation of your need as pseudocode:
For each string in Condition between first occurrence on a line of
//
and the next occurrence of/
For each occurrence of that same string in result, also between a leading double slash and single slash on a line
advance count
What I’d probably do is:
Prepare:
- Make safe copies of both files.
- Obtain a modern Windows “diff” (file & directory compare) tool. You can install the Compare plugin (Plugins, Admin…), but standalone ones are friendlier and more sophisticated and there are good free options.
Then:
- Clean both files so they contain only the strings of interest, one per line. This can be done with a macro (incorporating a {non-regex} find), or, a regex S&R. (Try learning and fooling around with these on your own. https://npp-user-manual.org/docs/searching/ If you need help, ask.)
- Sort first cleaned file (menu: Edit, Line operations).
- Sort second cleaned file.
- Use diff tool on the cleaned sorted files.
Now the mismatches in counts will jump out at you, and it will be much easier to count them.
Note that (a copy of) the cleaned (and maybe sorted, your preference) Condition file can be the start point for your report file.
If this is still too hard (because very big files, or, many entries, or done frequently) there will be a need for more sophistication.
Some fancy diff tools might have options to automate the counting.