Best way to read, and analyze a log file?

flit superflit at gmail.com
Tue Aug 1 17:00:09 EDT 2006


Thanks for all input..
I think I should put all data on a mysql base..
The company will need this for reports and statistics for a year.

bearophileHUGS at lycos.com wrote:
> superflit at gmail.com:
>
> > 1- Read the data and put all variables in a list
> > 2- Read the data and put all the variables in dictionary?
> > the logs is in this format
> > xxxxxxxxxxxxxxxxxxxxxxxxxx
> > The separation is by byte size like
> > xxx three bytes for code x , xxxx bytes for hour, etc..
> > I have two main objectives.
> > Show all data to user.
> > Analyze the data: like total sum, average,etc..
>
> If you want to do all by yourself you can create a list of starting
> positions, and you can add None to it, so you can use it to slice a
> line with a loop.
> You can also create a list of types, so you can cast the string parts
> to their correct types, catching the exceptions. You can do it in a
> second loop for clarity, or the first one to speed up a bit.
> So you can just create a list of data for each input line, a dict may
> be unnecessary because the number of fields seems fixed.
> 
> Bye,
> bearophile




More information about the Python-list mailing list