I am doing a text search in a rather big txt file (100k lines, 7mo) Text is not that big but I need a lot of searches. I want to look for a target string and return the line
text.count('\n',0,pos)
to get the line number.The loop in Python is slow. String searching is very fast. If you need to look for several strings, use regular expressions.
If that's not fast enough, use an external program like grep
.