I have a large text (4GB) which I am parsing. <div><br><div>I am reading the file to collect stats on certain items.</div><div><br></div><div>My approach has been simple,</div><div><br></div><div>for row in open(file):</div>
<div>  if "INFO" in row:</div><div>    line=row.split()</div><div>    user=line[0]</div><div>    host=line[1]</div><div>    __time=line[2]</div><div>    ...</div><div><br></div><div>I was wondering if there is a framework or a better algorithm to read such as large file and collect it stats according to content. Also, are there any libraries, data structures or functions which can be helpful? I was told about 'collections' container.  Here are some stats I am trying to get:</div>
<div><br></div><div>*Number of unique users</div><div>*Break down each user's visit according to time, t0 to t1</div><div>*what user came from what host. </div><div>*what time had the most users?</div><div><br></div><div>
(There are about 15 different things I want to query)</div><div><br></div><div>I understand most of these are redundant but it would be nice to have a framework or even a object oriented way of doing this instead of loading it into a database.  </div>
<div><br></div><div><br></div><div>Any thoughts or ideas? </div><div><br></div><div><br></div><div><br> <br>--- <span>Get your facts first, then you can distort them as you please.</span>--<br>
</div></div>