Re: [Tutor] Compute data usage from log

2009-10-27 Thread Eri Mendz
On Tue, Oct 27, 2009 at 7:24 PM, Dave Angel wrote: > (For some reason you keep top-posting.  Add your comments to the end, or > inline if appropriate) > Hi Dave, Noted the top posting thing thanks for reminding :-) > > In an earlier example, you already had a for loop on the log_file so the >

Re: [Tutor] Compute data usage from log

2009-10-27 Thread Eduardo Vieira
On Tue, Oct 27, 2009 at 5:33 AM, bibi midi wrote: > #!/usr/bin/env python > # -*- coding: utf-8 -*- > > ''' > Calculate internet data consumption > of service provider > Code as per help of python tutor mailing list > Created: 26-Oct-2009 > > ''' > > intro = raw_input('press enter to view your int

Re: [Tutor] Compute data usage from log

2009-10-27 Thread Dave Angel
(For some reason you keep top-posting. Add your comments to the end, or inline if appropriate) bibi midi wrote: 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 t

Re: [Tutor] Compute data usage from log

2009-10-27 Thread bibi midi
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 wrote: > >

Re: [Tutor] Compute data usage from log

2009-10-27 Thread Christian Witts
bibi midi wrote: Hey Christian, There seems to be a missing parenthesis in your join function below. Correct me if I'm wrong. I can live with ppp's time format for now. My script is not world-changing anyway :-). How do i know I'm on the last line of the log file per the code below? Just as

Re: [Tutor] Compute data usage from log

2009-10-27 Thread bibi midi
Hey Christian, There seems to be a missing parenthesis in your join function below. Correct me if I'm wrong. I can live with ppp's time format for now. My script is not world-changing anyway :-). How do i know I'm on the last line of the log file per the code below? Just asking as I'm away from m

Re: [Tutor] Compute data usage from log

2009-10-27 Thread Christian Witts
bibi midi wrote: #!/usr/bin/env python # -*- coding: utf-8 -*- ''' Calculate internet data consumption of service provider Code as per help of python tutor mailing list Created: 26-Oct-2009 ''' intro = raw_input('press enter to view your internet data consumption: ') log_file = '/home/bboymen/

Re: [Tutor] Compute data usage from log

2009-10-27 Thread bibi midi
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Calculate internet data consumption of service provider Code as per help of python tutor mailing list Created: 26-Oct-2009 ''' intro = raw_input('press enter to view your internet data consumption: ') log_file = '/home/bboymen/mobily.data.plan' to

Re: [Tutor] Compute data usage from log

2009-10-26 Thread bibi midi
On Mon, Oct 26, 2009 at 2:12 PM, Luke Paireepinart wrote: > > > On Mon, Oct 26, 2009 at 3:20 AM, Christian Witts > wrote: > >> fInput = open('/path/to/log.file', 'rb') >> total_usage = 0 >> for line in fInput: >> total_usage += int(line.split(' ')[9].strip()) >> print total_usage >> > > It's ac

Re: [Tutor] Compute data usage from log

2009-10-26 Thread Luke Paireepinart
On Mon, Oct 26, 2009 at 3:20 AM, Christian Witts wrote: > fInput = open('/path/to/log.file', 'rb') > total_usage = 0 > for line in fInput: > total_usage += int(line.split(' ')[9].strip()) > print total_usage > It's actually bad to assign a variable to the file object in this case (flinput = ...

Re: [Tutor] Compute data usage from log

2009-10-26 Thread Christian Witts
bibi midi wrote: Hi all! I have a file with data structure derived from wvdial log: Oct 14 11:03:45 cc02695 pppd[3092]: Sent 3489538 bytes, received 43317854 bytes. I want to get the 10th field of each line and get the sum for all lines (total my net data usage). In awk u can easily pop

[Tutor] Compute data usage from log

2009-10-26 Thread bibi midi
Hi all! I have a file with data structure derived from wvdial log: Oct 14 11:03:45 cc02695 pppd[3092]: Sent 3489538 bytes, received 43317854 bytes. I want to get the 10th field of each line and get the sum for all lines (total my net data usage). In awk u can easily pop it using field variabl