Skip to content

Instantly share code, notes, and snippets.

@chapinb
Last active August 29, 2015 14:09
Show Gist options
  • Save chapinb/af709f104e5374cf2b20 to your computer and use it in GitHub Desktop.
Save chapinb/af709f104e5374cf2b20 to your computer and use it in GitHub Desktop.
Read & Search lines of a file
fin = inputFile
fout = open('logfile.txt'), 'w')
flag = False
with open(fin, 'r') as infile:
content = infile.readline()
if content.startwith("diff --"):
content2 = infile.readline() # read next line and see if it has keyword
if content2.__contains__("keyword"):
fout.write(content)
cout.floush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment