Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/chat_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# To get the date
WDate = r'(?P<date>(?P<month>[0-9]{1,2})[-\/]{1}(?P<day>[0-9]{1,2})[-\/]{1}(?P<year>[0-9]{2}))'
# To get the time
WTime = r'(, (?P<time>(?P<hour>[0-9]{2}):(?P<minute>[0-9]{2})) )'
WTime = r'(, (?P<time>(?P<hour>[0-9]{1,2}):(?P<minute>[0-9]{2}) (?P<ampm>[AP]M)) )'
# Finally to get the parsed message
WMsg = WDate + WTime + WUser + r'(?P<message>.*)'

Expand Down Expand Up @@ -59,7 +59,7 @@ def import_data(path_to_chatfile: str) -> List[Dict[str, Any]]:
]
"""
try:
f = open(path_to_chatfile, 'r')
f = open(path_to_chatfile, 'r', encoding="utf-8", errors="ignore")
except FileNotFoundError:
print('File not found!!')
exit()
Expand Down Expand Up @@ -167,9 +167,10 @@ def import_data(path_to_chatfile: str) -> List[Dict[str, Any]]:
'month': match.groupdict()['month'],
'day': match.groupdict()['day'],
'year': match.groupdict()['year'],
'time': datetime.strptime(match.groupdict()['time'], '%H:%M').time(),
'time': datetime.strptime(match.groupdict()['time'], '%I:%M %p').time(),
'hour': match.groupdict()['hour'],
'minute': match.groupdict()['minute'],
'ampm': match.groupdict()['ampm'],
})
f.close()
return msgs
Expand Down