I have a text file (in an email format) that I need to extract out the hours (in HH:MM:SS format). I initially split the text but can't seem to split the results again to grab the time only. If I do manage to isolate the time and try again, it provides me with
AttributeError: 'list' object has no attribute 'split'"
Text Sample
From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008
Here is my code
name = input('Enter File:')
input to default to mbox-short.txt
if len(name) < 1 : name = 'mbox-short.txt'
handle = open(name)
counts = dict()
for line in handle:
line = line.rstrip()
if line.startswith('From '):
words = line.split()
time = words[5:6]
print(time)
hour = time.split(':')
print(hour)
The eventual goal is to build a histogram/time-series - any insights would be helpful to get past this part so I can continue!