title: Need to count them items from a list
body: <p>i need your help :)</p>
  
  <p>I have got a big log file called access_log.log with lot of lines like these (without the blank lines):</p>
  
  <pre><code>85.55.242.1 - - [22/Jan/2013:15:56:59 +0100] "GET /favicon.ico hxxp/1.1" 404 - "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/10.04 Chromium/18.0.1025.168 Chrome/18.0.1025.168 Safari/535.19"
  
  85.55.242.1 - - [22/Jan/2013:15:56:59 +0100] "GET /frutos.swf hxxp/1.1" 200 1454441 "hxxp://www.joquese.cat/frutos.html" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/10.04 Chromium/18.0.1025.168 Chrome/18.0.1025.168 Safari/535.19"
  
  85.55.242.1 - - [22/Jan/2013:15:56:59 +0100] "GET /plujasecs_mudo.flv hxxp/1.1" 200 1325949 "hxxp://www.joquese.cat/frutos.swf" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/10.04 Chromium/18.0.1025.168 Chrome/18.0.1025.168 Safari/535.19"
  
  88.2.214.254 - - [22/Jan/2013:16:25:23 +0100] "GET / hxxp/1.1" 200 2722 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.17 (KHTML, like Gecko) Version/6.0.2 Safari/536.26.17"
  </code></pre>
  
  <p>I'm "fighting" with python to extract the referrers from each line and list them with the numbers of copies from the 50 most common. I know it will be so easy with "awk" but I want to learn how to do it with python. What I have done is to mark the blank space as a field separator and take the strings between the fields number ten and eleven.</p>
  
  <pre><code>arxiu_de_log = open("access_log.log","r")
  linies = arxiu_de_log.readlines()
  arxiu_de_log.close() 
  
  clean_log=[]
  for line in linies:
      try:
          separador_de_linea=line.split(' ')
          camp_de_referer = separador_de_linea[10:11]
          clean_log.append(camp_de_referer)
  
      except:
          pass
  
  print clean_log
  </code></pre>
  
  <p>When I run the program what I get is:</p>
  
  <pre><code>[['"-"'], ['"hxxp://www.joquese.cat/frutos.html"'], ['"hxxp://www.joquese.cat/frutos.swf"'], ['"-"'], ['"hxxp://www.joquese.cat/"']
  </code></pre>
  
  <p>But I would like something similar to:</p>
  
  <pre><code>2   "-"
  
  1   "hxxp://www.joquese.cat/frutos.swf"
  
  1   "hxxp://www.joquese.cat/frutos.swf"
  
  1   "hxxp://www.joquese.cat/"
  
  ....
  </code></pre>
  
  <p>I have tried to program the counter with something similar to:</p>
  
  <pre><code>import collections
  ...
  counter = collections.Counter(clean_log)
  
  for count in counter.most_common(50):
      print(str(count[1])+"\t"+ str(count[0]))
  </code></pre>
  
  <p>But I can't make it work properly, can you help me?</p>