title: counting database hits by user type in python
body: <p>I have a reverse access log file that I've processed to just be the url hit and user type. I need to count the number of times a given url is hit by each of the user types. 
  sample data:</p>
  
  <blockquote>
    <p><a href="http://find.galegroup.com:80/" rel="nofollow noreferrer">http://find.galegroup.com:80/</a> staff
       <a href="http://www.transnational-dispute-management.com:80/" rel="nofollow noreferrer">http://www.transnational-dispute-management.com:80/</a> student
       <a href="https://www.investorstatelawguide.com:443/" rel="nofollow noreferrer">https://www.investorstatelawguide.com:443/</a> AdjunctVisiting
       <a href="https://www.jstor.org:443/" rel="nofollow noreferrer">https://www.jstor.org:443/</a> faculty
       <a href="https://bmo.bmiresearch.com:443/" rel="nofollow noreferrer">https://bmo.bmiresearch.com:443/</a> mainlibrary
       <a href="https://heinonline.org:443/" rel="nofollow noreferrer">https://heinonline.org:443/</a> oncampus
       <a href="http://find.galegroup.com:80/" rel="nofollow noreferrer">http://find.galegroup.com:80/</a> student</p>
  </blockquote>
  
  <p>I was thinking to put each url as a tuple with counters for each user type. As each line is read it is tested against previous matches - if it doesn't have any matches then a new tuple is initiated. If it does have a match, the appropriate counter is incremented and the tuple resaved.</p>
  
  <p>At the end all the tuples are written out to a new file.</p>
  
  <p>Problem is I haven't a clue how to implement it.</p>
  
  <p>Pointers, general strategies, and answers greatly appreciated!</p>