[Tutor] Compute data usage from log

bibi midi bibsmendez at gmail.com
Mon Oct 26 08:45:06 CET 2009

Hi all!

I have a file with data structure derived from wvdial log:
Oct 14 11:03:45 cc000002695 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 variables
e..g $10. Since im learning python on my own i thought this is a good way to
learn but im stumped how to achieve this goal.
I used open() and read line method to store the contents in a list but it is
a list of string. I need it to be numbers. Iterating through the string list
definitely is unwieldy. Can you guys advise best way how?

FWIW im a self learner and just relying from tutorial materials and this
medium to learn python. Lead me to the right direction please :-)

My IDE is vim and ipython in debian linux.

Best Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091026/48b01e01/attachment.htm>

More information about the Tutor mailing list