Python:
I have a particular word which Iam looking in a text file of large size which is in millions of records.
So actually i wanted to search if a particular string is availabe in the file.
One way i did is :
with open('ip.log', 'r') as f:
for line in f:
if semething in line:
break
else:
print 'Not found'
But for small files this process will be fine,but when file size increases or records grow to tens of millions.Loading that big file into memory may not be a feasible solution.
Is there any better way to deal with this problem?
Observations:
- If file is so huge of 1GB or something, it will slow up the system
- Looking for one text we need to iterate over millions of records each time.