This is just an example with python with no checking the existence of the file or other and i have to say that i found all of this over the INTERNET i just put the pieces together so there may be many other ways to do this.
At the beggining i tougth that python were not so good because i does not have any hash structure but it has many other it simplifies the perl version of course im talking of my franken_perl_version (:{
#!/usr/bin/python
#Counter:
# A Counter is a container that tracks how many times equivalent values are
# added.It can be used to implement the same algorithms for which other
# languages commonly use bag or multi-set data structures.
import sys;
from collections import Counter;
users = [];
for line in open(sys.argv[1], "r"):
e = line.split();
users.append(e[8]);
c = Counter(users);
for k in users:
print '%s : %d' % (k, c[k]);
No comments:
Post a Comment