[Tutor] Compute data usage from log
bibsmendez at gmail.com
Mon Oct 26 08:45:06 CET 2009
I have a file with data structure derived from wvdial log:
Oct 14 11:03:45 cc000002695 pppd: Sent 3489538 bytes, received
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor