Message Boards Message Boards

Analyze your WhatsApp Chat

Posted 3 years ago

This post is to share a simple code that allows you to visualize some statistics and trends of your individual or group chats in WhatsApp! The main results are:

  • Time Series of the messages in the group or conversation
  • Pie Chart showing the number of messages sent by each person
  • Bar Chart showing the time in which every person send more messages
  • And more.. !

Download your WhatsApp conversation is really easy, just follow the 3 simple steps shown in this link: https://faq.whatsapp.com/android/chats/how-to-save-your-chat-history/?lang=en. Just make sure your phone is in 24h-format exporting your chat!

An example (with changed names) is: enter image description here

Let me know any doubts or suggestions to improve this notebook!

8 Replies
Posted 3 years ago
POSTED BY: trinko
Posted 3 years ago

For your first error regarding that Length@messages == Length@datesAndTime returns false, I think the problem is that the script doesn't take it into account the fact that some users use the 12-hour clock which has AM and PM at the end of the string. A simple fix would be to replace the assignment of datesAndTime with:

datesAndTime = 
 StringSplit /@ 
  StringCases[rawData, 
   "[" ~~ x : (DigitCharacter .. ~~ "/" ~~ DigitCharacter .. ~~ "/" ~~
         DigitCharacter .. ~~ Whitespace ~~ DigitCharacter .. ~~ ":" ~~
         DigitCharacter .. ~~ ":" ~~ DigitCharacter .. ~~ Whitespace ~~
         LetterCharacter ..) ~~ "]" -> x]

and the assignment of messages with:

messages = 
  StringSplit[rawData, 
   "[" ~~ DigitCharacter .. ~~ "/" ~~ DigitCharacter .. ~~ "/" ~~ 
    DigitCharacter .. ~~ Whitespace ~~ DigitCharacter .. ~~ ":" ~~ 
    DigitCharacter .. ~~ ":" ~~ DigitCharacter .. ~~ Whitespace ~~ 
    LetterCharacter .. ~~ "]" ~~ Whitespace ..];

I don't get any other errors after fixing that. Let me know if this works for you!

POSTED BY: Ivo Malinowski

That is not the problem for me. My file contains 24h format. Messages has one element, datesAndTime is empty. I think it is because my dates have European format. I am really new to Mathematica and got this link send after registering for the free trial and it looked cool. Can you explain how I should change the Code for dates in the form of

[17.03.20, 08:59:46] <name>: <message>

? Thanks :)

POSTED BY: Laurenz Hemmen

I replaced "/" with ".", but it did not change anything. messages looks like the same as rawData but with curly braces around it {}. messages == {rawData} evaluates to true.

Update: Fixed this problem now. (Still some other things to change for European date format) Had to also add `~~","~~ between date and time in my format.

POSTED BY: Laurenz Hemmen
Posted 3 years ago

I posted an example of the file and it uses 24 hour time

[2/6/16, 23:57:17] ‎name1 created group “random fake chat name”

[2/6/16, 23:57:17] ‎name1 added you

[2/6/16, 23:57:46] name1: How's almost super bowl??

[2/7/16, 08:39:18] name2: So there were a total of

So that can't be the problem. Other thoughts? Does this data look like the data you used?

And thanks for replying so quickly!

POSTED BY: trinko
Posted 3 years ago

Thanks Ivan, even though I find it is not that simple to do but you had given a good and 'simple' explanation on the how.

POSTED BY: Yasmin Hussain

enter image description here -- you have earned Featured Contributor Badge enter image description here

Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

POSTED BY: Moderation Team
Posted 3 years ago

Thanks Ivan.

Though, our definitions of "simple" might be a bit different; examples like this not only help me to better understand what Wolfram can do, they help me to imagine what I might be able to do with Wolfram.

POSTED BY: Mike Besso
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract