Skip to content

Parse and filter WhatsApp logs (from the "Email chat" option) in Python3

License

Notifications You must be signed in to change notification settings

richiedunk/pyWhatsAppLog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Analysing WhatsApp messages with AWS

The first step is to export your WhatsApp messages. I just downloaded a text file without media attachements, but you could put them in an S3 bucket or something if you wanted to.

pyWhatsAppLog

A Python3 class to parse and analyse WhatsApp logs

Use with

from whatsapplog import WhatsAppLog

parser = WhatsAppLog(source)
parser.parse()

The source can either be a filepath or a raw string. parser.parsed is True after a parse() has succeeded.

parser.filter(criteria) returns a filtered list of messages. The filters are named arguments and take the form...

  • DateTime beforedatetime: Any message sent on or before this date/time will be returned
  • DateTime afterdatetime: Any message sent on or after this date/time will be returned
  • String sendercontains: Returns any message where the sender name contains this string.
  • String textcontains: Returns any message where the message text contains this string.

So examples might be...

results = parser.filter(beforedatetime = datetime(2018, 1, 31, 17, 0), afterdatetime = datetime(2018, 1, 1, 9, 0))
# returns all messages sent between 9am on 1 January 2018 and 5pm on 31 January 2018

results = parser.filter(sendercontains = "Jim")
# returns all messages where the sender name contains "Jim" - so will include Jim, Jimmy, Jimbo etc

results = parser.filter(textcontains = "dog")
# returns all messages containing the word "dog"

results = parser.filter(textcontains = "birthday", sendercontains = "Queen", afterdatetime = datetime(2019, 6, 13, 0, 0))
# returns all messages the Queen might have sent you about her birthday after it happened

About

Parse and filter WhatsApp logs (from the "Email chat" option) in Python3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages