Last active
December 30, 2015 16:21
-
-
Save ltc-hotspot/60e72b5a3bf73a4c783f to your computer and use it in GitHub Desktop.
Meta Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handle = """From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 | |
From louis@media.berkeley.edu Fri Jan 4 18:10:48 2008 | |
""".split("\n") # snippet file data: Source-Metadata.txt | |
count = dict() | |
fname = raw_input("Enter file name: ")# insert # to add snippet file data | |
handle = open (fname, 'r')# insert # to add snippet file data | |
for line in handle: | |
if line.startswith("From "): | |
time = line.split() # splitting the lines -> | |
# print time: ['From', 'stephen.marquard@uct.ac.za', 'Sat', 'Jan', '5', '09:14:16', '2008'] | |
for hours in time: #getting the index pos of time -> | |
hours = line.split(":")[2] # splitting on ":" -> | |
line = line.rstrip() | |
count[hours] = count.get(hours, 0) + 1 # getting the index pos of hours. | |
lst = [(val,key) for key,val in count.items()] # find the most common words | |
lst.sort(reverse=True) | |
for key, val in lst[:12] : | |
print key, val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment