day 4, part 1 and part 2 (2 failing)

This commit is contained in:
Xevion
2019-07-26 17:14:47 -06:00
parent 17b61b6cd7
commit 78b43513a7
4 changed files with 1168 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import sys, os, re, datetime
# Patterns for Regex and STRPTIME function
timepattern = r"\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2})\](.+)"
strptimepattern = "%Y-%m-%d %H:%M"
def getDateTime(string):
return datetime.datetime.strptime(re.match(timepattern, string).group(1), strptimepattern)
def process():
newpath = os.path.join(sys.path[0], '..', 'processed_input')
path = os.path.join(sys.path[0], '..', 'input')
data = open(path, 'r').read().split('\n')
return sorted(data, key=getDateTime)