Re: better way to do this in python

2011-04-04 Thread nn
On Apr 3, 8:06 am, Mag Gam magaw...@gmail.com wrote: Thanks for the responses. Basically, I have a large file with this format, Date INFO username command srcipaddress filename I would like to do statistics on: total number of usernames and who they are username and commands username and

Re: better way to do this in python

2011-04-03 Thread Mag Gam
Thanks for the responses. Basically, I have a large file with this format, Date INFO username command srcipaddress filename I would like to do statistics on: total number of usernames and who they are username and commands username and filenames unique source ip addresses unique filenames

better way to do this in python

2011-04-02 Thread Mag Gam
I have a file like this, cat file aaa bbb aaa aaa aaa awk '{x[$1]++}END { for (i in x) {print i,x[i]} } ' test bbb 1 aaa 4 I suppose I can do something like this. (pseudocode) d={} try: d[key]+=1 except KeyError: d[key]=1 I was wondering if there is a pythonic way of doing this? I plan

Re: better way to do this in python

2011-04-02 Thread Chris Angelico
On Sun, Apr 3, 2011 at 9:58 AM, Mag Gam magaw...@gmail.com wrote: I suppose I can do something like this. (pseudocode) d={} try:  d[key]+=1 except KeyError:  d[key]=1 I was wondering if there is a pythonic way of doing this? I plan on doing this many times for various files. Would the

Re: better way to do this in python

2011-04-02 Thread Dan Stromberg
On Sat, Apr 2, 2011 at 5:24 PM, Chris Angelico ros...@gmail.com wrote: On Sun, Apr 3, 2011 at 9:58 AM, Mag Gam magaw...@gmail.com wrote: I suppose I can do something like this. (pseudocode) d={} try: d[key]+=1 except KeyError: d[key]=1 I was wondering if there is a