mirror of
https://github.com/Xevion/advent-of-code.git
synced 2025-12-07 13:14:24 -06:00
day 4, part 1 and part 2 (2 failing)
This commit is contained in:
14
2018/day-4/python/process_input.py
Normal file
14
2018/day-4/python/process_input.py
Normal 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)
|
||||
Reference in New Issue
Block a user