I have following file text.text:-
08-JUN-2013 05:04:02
08-JUN-2013 05:04:02
08-JUN-2013 05:04:02
08-JUN-2013 05:04:03
08-JUN-2013 05:04:03
08-JUN-2013 05:05:23
08-JUN-2013 05:05:23
08-JUN-2013 05:05:23
08-JUN-2013 05:05:23
I want to print something like this using Python:-
08-JUN-2013 05:04:02 ------3
08-JUN-2013 05:04:03-------2
08-JUN-2013 05:05:23-------4
Here is what i did on this and i am newbie here :-
"
import re
pattern = re.compile("\d+-\w+-\d+\s\d+:\d+:\d+")
open_file=open('mytest.txt')
for line in open_file:
four_letter_words = pattern.findall(line)
fp_len = len(pattern.findall(line))
for word in four_letter_words:
print four_letter_words , fp_len
"