title: How do I get Information from log file's last modified using Python?
body: <p>I am new to Python and I am trying to create a script to go through all of my daily log files to check for errors.</p>
  
  <p>I can open the files, print the last time the log file was modified, and print out any errors in the log file.</p>
  
  <p>However, these logs have daily information for the past three years in them.  I want to be able to only read the section of the log from the last modified date of the log (Instead of getting all errors from the past three years, I only want the error from the last day.) </p>
  
  <p>Here is what I have for my script so far:</p>
  
  <pre><code>import sys, string, os, time
  
  from stat import *
  
  from datetime import datetime
  
  now = datetime.now()
  
  f3 = 'C:\Path\filename.txt'
  
  seconds = os.path.getmtime(f3)
  print "Last Date Ran: ", time.strftime('%m/%d/%Y %H:%M:%S' , time.localtime(seconds))
  
  for line in open(f3 , 'r'):
      if 'error' in line:
          print "&gt;&gt;&gt; " , line
      elif 'Error' in line:
          print "&gt;&gt;&gt; " , line
      elif 'ERROR' in line:
          print "&gt;&gt;&gt; " , line
  </code></pre>
  
  <p>Is there any way to do this?  I have searched high and low and not found an answer to my problem.  Please help.</p>