I want to change the output of my code. I have a code like this :
from collections import defaultdict
third = defaultdict(lambda: (defaultdict(lambda : defaultdict(int))))
count = 0
fh = open("C:/Users/mycomp/desktop/data.txt", "r").readlines()
for line in fh:
line_split = line.split();
date = line_split[0];
time = line_split[1];
ip = line_split[2];
third [date][time][ip]+= 1
for date, d in third.iteritems():
for time , count in d.iteritems():
print "%s %s %s %s" % (date, time, count,ip)
Log file like this :
2016-11-04 00:00:12 10.11.13.13
2016-11-05 00:00:15 10.14.12.11
2016-11-06 00:00:19 10.10.15.13
My output is like below.
2016-10-04 07:46 defaultdict(<type 'int'>, {'10.11.13.15': 574}) 10.11.13.15
2016-10-04 15:58 defaultdict(<type 'int'>, {'10.21.24.13': 364}) 10.21.24.13
2016-10-04 15:59 defaultdict(<type 'int'>, {'10.21.22.13': 359}) 10.21.22.13
2016-10-04 07:42 defaultdict(<type 'int'>, {'10.21.27.10': 287}) 10.21.27.10
2016-10-04 07:43 defaultdict(<type 'int'>, {'10.11.37.13': 337}) 10.11.37.13
but ı want an output like this :
2016-10-04 07:46 {'10.11.13.15': 574}) 10.11.13.15
2016-10-04 15:58 {'10.21.24.13': 364}) 10.21.24.13
2016-10-04 15:59 {'10.21.22.13': 359}) 10.21.22.13
2016-10-04 07:42 {'10.21.27.10': 287}) 10.21.27.10
2016-10-04 07:43 {'10.11.37.13': 337}) 10.11.37.13