title: How to count accesses per hour from log file entries?
body: <p>I have a log-file where every line contains IP address, time of access, and the URL accessed. I want to count the accesses per hour.</p>
  
  <p>Time of access data looks like this</p>
  
  <pre><code>[01/Jan/2017:14:15:45 +1000]
  [01/Jan/2017:14:15:45 +1000]
  [01/Jan/2017:15:16:05 +1000]
  [01/Jan/2017:16:16:05 +1000] 
  </code></pre>
  
  <p>How can I improve it so I don't need to set up the variable and if statement for every hour?</p>
  
  <pre><code>twoPM = 0
  thrPM = 0
  fouPM = 0
  timeStamp = line.split('[')[1].split(']')[0]
  formated_timeStamp = datetime.datetime.strptime(timeStamp,'%d/%b/%Y:%H:%M:%S %z').strftime('%H')
  if formated_timeStamp == '14':
      twoPM +=1
  if formated_timeStamp == '15':
      thrPM +=1
  if formated_timeStamp == '16':
      fouPM +=1
  </code></pre>