-
-
Save amankharwal/8b6f03bbc4900cff948a867c07eef148 to your computer and use it in GitHub Desktop.
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
def date_time(s): | |
pattern = '^([0-9]+)(\/)([0-9]+)(\/)([0-9]+), ([0-9]+):([0-9]+)[ ]?(AM|PM|am|pm)? -' | |
result = regex.match(pattern, s) | |
if result: | |
return True | |
return False | |
def find_author(s): | |
s = s.split(":") | |
if len(s)==2: | |
return True | |
else: | |
return False | |
def getDatapoint(line): | |
splitline = line.split(' - ') | |
dateTime = splitline[0] | |
date, time = dateTime.split(", ") | |
message = " ".join(splitline[1:]) | |
if find_author(message): | |
splitmessage = message.split(": ") | |
author = splitmessage[0] | |
message = " ".join(splitmessage[1:]) | |
else: | |
author= None | |
return date, time, author, message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment