with open('largeFile', 'r') as inF:
for line in inF:
if 'myString' in line:
# do_something
# Open the file
fhand = open('path and the name of the file')
count = 0
# iterate through the lines in the file
for line in fhand:
# Remove the
at the end and stop printing an empty line
line = line.rstrip()
if 'sub string' in line:
count += 1
print(count, line)
# Close the file
fhand.close()
import mmap
with open('example.txt') as f:
s = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
if s.find('blabla') != -1:
print('true')