Module : SearchFile
Parameters : input file , string to be
searched
output : 1 - > if the string founds
inside the file , 0 -> if the string doesnot present in the file
This Modules opens the input file and
scan line by line for the specified string . If the particular string
is found, the module returns 1. If the particular string is not found
it returns 0
Example:
if cricket.txt file contains
Sachin
Shewag
Dhoni
SearchFile("cricket.txt","Sachin")
will return 1
SearchFile("cricket.txt","Sania")
will return 0
The key needs to be searched is case
sensitive,
SearchFile("cricket.txt","sachin")
will return 0
def SearchFile(filename,key): fileptr = open(filename, "r") for line in fileptr: if string.find(line,key) >=0 : fileptr.close() return 1 fileptr.close() return 0
Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you Best tracer router service provider.