Need Help Opening, Parsing, and Closing a File in Python [closed]

Opening a file:

myLog = open("path/to/my/log", 'r')

Loop through the lines:

for line in myLog:
    if foundMyThing(line):
        print "Found it!"

Close it:

myLog.close()

Read the docs:

https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files

Leave a Comment