AnalyzeTheChat — Python-based WhatsApp chat analyzer

Aqeel Anwar
3 min readJun 28, 2020

--

Analyze your WhatsApp chat in the form of interesting graphs

A couple of weeks ago my wife and I started looking at our Whatsapp chat over the last year. There were too many messages and we simply couldn’t go over all of them. I have been using Python for over 3 years now and thought of creating a very simple analyzer to provide me with some useful insights into our WhatsApp chat. The resulting graphs were pretty interesting.

In this article, I will go through the GitHub repository I created for analyzing WhatsApp chat.

AnalyzeTheChat Online Demo:

To check out the online easy-to-use demo without going through the hassle of installing the repository and Python packages, please click below and follow the instructions.

What is AnalyzeTheChat?

AnalyzeTheChat is a Python-based repository to generate useful statistics for your WhatsApp chat. It crawls the provided .txt file of the WhatsApp chat and generates a pandas dataframe. This dataframe is then processed to plot the following contact-wise and time-wise statistics

Contact-wise statistics:

  • Number of messages per contact
  • Number of words per contact
  • Number of average words per message per contact
  • Number of emojis per contact
  • The average number of emojis per message per contact
  • Number of Media per contact
  • Number of keywords per contact

Time-wise statistics

  • Number of messages per hour
  • Number of messages per weekday
  • Number of messages per month
  • Number of messages per year

An example of generates statistics can be seen below

How to Install AnalyzeTheChat?

It is advisable to make a new virtual environment (with python 3.6) for this project. Step-by-Step details on creating a virtual environment can be found here

1. Clone the repository

Once you have created the virtual environment, activate it, and use the following command to clone the repository.

git clone https://github.com/aqeelanwar/AnalyzeTheChat.git

2. Install the required packages

cd AnalyzeTheChat
pip install -r requirements.txt

How to run AnalyzeTheChat?

1. Export the WhatsApp chat

Export the WhatsApp chat you like to analyze using the following steps

  1. Open the WhatsApp chat
  2. Click the three vertical dots on top-right
  3. Click More
  4. Click Export Chat
  5. Click Without Media
  6. Save the generated .txt file where it is accessible
Image: https://github.com/aqeelanwar/AnalyzeTheChat

2. Execute the code

# Generic
python main.py --path <path-to-chat> --save_as <save-type>
# Example
python main.py --path theoffice.txt --keyword 'jello' --save_as pdf

3. Arguments

Image: https://github.com/aqeelanwar/AnalyzeTheChat

View the results

The results are saved in the results folder in the format selected by the user through the argument save_as.

Summary:

AnalyzeTheChat is a python-baed WhatsApp chat analyzer that generates interesting bar graphs. It can be used to analyze the activity of a person or a group chat to deduce useful results. The online demo can be found here

--

--