Skip to content

Commit

Permalink
Select by column name instead of index in counting function
Browse files Browse the repository at this point in the history
Resolves the problem with occurrences of sender_id_INTERNAL in .json files
  • Loading branch information
KMChris committed Jul 7, 2022
1 parent 9de3e37 commit ac75031
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions MessengerCounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ def count_messages():
i += 1
messages += collections.Counter(pd.DataFrame(json.loads(
source.open('messages/inbox/' + sender + '/message_' + str(i) + '.json').read())[
'messages']).iloc[:, 0])
'messages'])['sender_name'])
except KeyError:
try:
messages += collections.Counter(pd.DataFrame(json.loads(
source.open('messages/archived_threads/' + sender + '/message_' + str(i) + '.json').read())[
'messages']).iloc[:, 0])
'messages'])['sender_name'])
except KeyError:
break
total[sender] = {k.encode('iso-8859-1').decode('utf-8'): v for k, v in messages.items()}
Expand Down

0 comments on commit ac75031

Please sign in to comment.