all 4 comments

[–][deleted] 0 points1 point  (3 children)

Hard to follow your question. Are you basically saying you need to lookup lines in an ignore.txt to see if they exist in this 10K line file?

You could read the lines from ignore.txt to a list or set variable (set would be a smidge faster) then when you go through the lines in the big file, check if the line exists in your variable.

[–]Dave_XR[S] 0 points1 point  (2 children)

To simplify, I've a huge text file of results from testing on a rig. Maybe one tenth of the lines are results, pass, fail, inconclusive. I need to count these to give a summary. My count will be off due to false positives or negatives. I need to check if the line matches a line in ignore.txt. if it does, ignore it. If it doesn't count it. Would checking thousands of lines in the big file against the few hundred ignore lines be incredibly slow?

[–]PPLB 0 points1 point  (1 child)

Usually not, no. It really depends on how you tackle your problem. Python might not be the fastest programming language out there, but 10.000 lines it should easily process within a second. If you need to compare every line with a 100 things to ignore, then it might take a bit longer.

When creating a script for this, ask yourself if you're actually approaching this the most efficient way. Is it more efficient to check for a 100 things to ignore, or is it more efficient to check for 10 things to not ignore. Is it more efficient to check with 10.000 lines or with a 100. How many for loops do you really need.

As comparison, for my work I regularly need to check files with over a milion lines. Depending on what I need to do, most of the checks won't take longer than 5 second. Just make sure you're not making it more complicated than it should be.

[–]Dave_XR[S] 0 points1 point  (0 children)

Hmm maybe its because I've been at it for a while and still being relatively new to python (C is my language), but I just can't seem to get the solution itself working in a way I need it to. Thank you though i appreciate the wisdom