<div dir="ltr"><p>I have a written a generator for an apache log which returns two types of information, <br>hostname and the filename requested.</p>
<p>The 'log' generator can be 'consumed' like this:</p>
<p>for r in log:<br>  print r['host'], r['filename']</p>
<p>I want to find the top '100' hosts (sorted in descending order of total requests) like follows:</p>
<p>host  filename1  filename2 filename3 ....    Total</p>
<p>hostA   6          9         45                         110<br>hostC   4         43        43                          98<br>hostB   34        4         45                          83</p>
<p>and so on.</p>
<div>Is there a fast way to this without scanning the log file many times?<br>Thanks in advance.</div>
<div>- Jo</div></div>