title: Python how to use Counter() function with Apache Log Files?
body: <p>I am fairly new to Python programming and I am creating an Apache log parser. I came around a Counter function from 'import collections'. I am trying to reduce the amount of lines, because currently I am counting my IP occurances like this:</p>
  <pre><code>if sort == 'ip':
      ip_count = []
      for match in ip_list:
          count = 0
          for ip_match in ip:
              if match == ip_match:
                  count += 1
          ip_count.append(count)
  </code></pre>
  <p>and my bytes like this:</p>
  <pre><code> if desired_output == 'bytes':
              cnt_bytes = []
              for v in range(len(ip_list)):
                  tmp = 0
                  for k in range(len(ip)):
                      if ip_list[v] == ip[k]:
                          if bytes[k] == '-':
                              bytes[k] = 0
                          tmp += int(bytes[k])
                  cnt_bytes.append(tmp)
  </code></pre>
  <p>It seems unpythonic.</p>
  <p>ip_list[] is a list of unique ip addresses.
  ip_count[] stores the count for each ip address.</p>
  <p>Is there a way to reduce these lines of code with Counter() function?</p>