Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[whatsapp] Support loading txt files from subdirectories #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
5 changes: 2 additions & 3 deletions parsers/whatsapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def infer_datetime_regex(f_path, max_messages=100):
with open(f_path, 'r', encoding="utf8") as f:
for c, line in enumerate(f):
if c == max_messages:
break;
break
matches = regex_message.search(line.upper())
if matches:
pattern = ""
Expand Down Expand Up @@ -67,7 +67,7 @@ def main(own_name, file_path, max_exported_messages, infer_datetime):
global MAX_EXPORTED_MESSAGES
MAX_EXPORTED_MESSAGES = max_exported_messages
log.info('Parsing Whatsapp data...')
files = glob.glob(os.path.join(file_path, '*.txt'))
files = glob.glob(os.path.join(file_path, '*', '*.txt'))
if len(files) == 0:
log.error(f'No input files found under {file_path}')
exit(0)
Expand All @@ -91,7 +91,6 @@ def parse_messages(files, own_name, infer_datetime):
data = []
for f_path in files:
log.info(f'Reading {f_path}')
f_name = os.path.basename(f_path)
conversation_id = uuid.uuid4().hex
participants = set()
conversation_data = []
Expand Down