Thanks Andrea. I was thinking that too but I was wondering if there were any other clever ways of doing this. <br>I also though, I can build a filesystem structure depending on the __time. So, for January 01, 2011. I would create /tmp/data/20110101/data . This way I can have a fast index of the data. And next time I read thru this file, I can skip all of Jan 01, 2011<br>
<br><br><br><br><div class="gmail_quote">On Sat, Feb 26, 2011 at 10:29 AM, Andrea Crotti <span dir="ltr"><<a href="mailto:andrea.crotti.0@gmail.com">andrea.crotti.0@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Il giorno 26/feb/2011, alle ore 06.45, Rita ha scritto:<br>
<div><div></div><div class="h5"><br>
> I have a large text (4GB) which I am parsing.<br>
><br>
> I am reading the file to collect stats on certain items.<br>
><br>
> My approach has been simple,<br>
><br>
> for row in open(file):<br>
>   if "INFO" in row:<br>
>     line=row.split()<br>
>     user=line[0]<br>
>     host=line[1]<br>
>     __time=line[2]<br>
>     ...<br>
><br>
> 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:<br>

><br>
> *Number of unique users<br>
> *Break down each user's visit according to time, t0 to t1<br>
> *what user came from what host.<br>
> *what time had the most users?<br>
><br>
> (There are about 15 different things I want to query)<br>
><br>
> 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.<br>
><br>
><br>
> Any thoughts or ideas?<br>
<br>
</div></div>Not an expert, but maybe it might be good to push the data into a database, and then you can tweak the DBMS and write<br>
smart queries to get all the statistics you want from it.<br>
<br>
It might take a while (maybe with regexp splitting is faster) but it's done only once and then you work with DB tools.<br>
<br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>--- <span>Get your facts first, then you can distort them as you please.</span>--<br>