[Tutor] Compute data usage from log

bibi midi bibsmendez at gmail.com
Tue Oct 27 14:21:18 CET 2009


Yep it works! I understand now it iterates on each line and replaces the old
elements with the new ones. In the end you get the latest date of the last
line of log.

I will work on the exception handling and other refinements. Thanks.



On Tue, Oct 27, 2009 at 8:41 AM, Christian Witts <cwitts at compuscan.co.za>wrote:

>
>
>>    for line in open(log_file):
>>      last_log_date = ' '.join(line.split(' ')[:3]
>>
>>    which would take the first 3 elements in your list and combine
>>    them again.  Of course this is again just a simple representation
>>    of what to do.
>>
>>    --    Kind Regards,
>>    Christian Witts
>>
>>
>>
>>
>>
>> --
>> Best Regards,
>> bibimidi
>>
>> Sent from Riyadh, 01, Saudi Arabia
>>
>
>
> Hi Bibi,
>
> Yeah there was a missing parenthesis, I was just typing away.
> As for knowing if you're on the last line of your log file, basically what
> will happen is for every line you iterate through it will parse the first 3
> elements of your line and use that for the last_log_date.
> If you know for certain that every line will start with the time stamp then
> it will work fine, if that is not the case then you will need to build in
> some checking to ensure you get the correct information.
>
> --
> Kind Regards,
> Christian Witts
>
>
>


-- 
Best Regards,
bibimidi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091027/8c263bf9/attachment.htm>


More information about the Tutor mailing list