├── LICENSE ├── README.md ├── chatAnalyzer.py └── image1.png /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Ghulam Mohiyuddin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Chat_Analyzer

2 | 3 | [![forthebadge made-with-python](http://ForTheBadge.com/images/badges/made-with-python.svg)](https://www.python.org/)
4 | [![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/subahanii/Whatsapp-Chat-Analyzer/blob/master/LICENSE) 5 | [![Open Source Love svg1](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/) 6 | [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/subahanii/Whatsapp-Chat-Analyzer/issues) 7 | 8 | 9 | ## INTRODUCTION: 10 | This script for whatsapp group/individual chat analyzer .
11 | This script is able to analyse all activity happened in whatsapp group and visualize all thing through matplotlib library. 12 |


13 | ## Application: 14 | 1- Count total chat.
15 | 2- Count total chat person wise.
16 | 3- showing top active member.
17 | 4- How many messages are deleted during conversation.
18 | 5- Identify more conversation days.
19 | 6- Identify current Admin and how many admin changed till now.
20 | 7- And many more. 21 |


22 | 23 | 24 | 25 | ## Images: 26 | 27 | 28 | 29 |


30 | ## Prerequisites: 31 | 1- Python interprater with matplotlib,pandas,NumPy library*
32 | 2- Jupyter NoteBook (optional)
33 | 3- Whatsapp chat data* (.txt file)--->Dataset
34 | ## How to found chat data from Whatsapp: 35 | 1-open whatsapp group
36 | 2-tap right-uper corner and goto more option
37 | 3- tap on "Export Chat"
38 | 4- tap on "Without Media"
39 | 5- finally you will get .txt file well done.
40 | 41 | ### Contributions :smiley:[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/subahanii/Whatsapp-Chat-Analyzer/issues) 42 | Contributions always welcome . 43 | 44 | ### Thank You.:pray: 45 | ##### If you like this please appreciate by giving start and Fork this repo.Thank You...! :clap: :clap: :clap: 46 | 47 | 48 | -------------------------------------------------------------------------------- /chatAnalyzer.py: -------------------------------------------------------------------------------- 1 | """ 2 | Author : Ghulam Mohiyuddin 3 | What is this: This is a whatsapp group/indivisual chat analyser 4 | Note: This is not a final, wait for more functionality 5 | """ 6 | 7 | 8 | 9 | import os 10 | import re 11 | import pandas as pd 12 | import matplotlib.pyplot as plt 13 | link="C:\\Users\\asus\\Downloads\\WhatsApp Chat with Unemployed peeps.txt" 14 | tit=link.split("\\") 15 | title=tit[-1] 16 | title1=title[:len(title)-4:] 17 | print(title1) 18 | cht=open(link,encoding="utf8") 19 | list_of_date_time_author_msg=[] 20 | total_msg=0 21 | total_msg_and_notification=0 22 | list_of_notification=[] 23 | total_valid_msg=0 24 | 25 | def startsWithDate(s): 26 | #ReGex finding date and time 27 | pattern = "^([0-2][0-9]|(3)[0-1])(\/)(([0-9])|((0)[0-9])|((1)[0-2]))(\/)(\d{2}|\d{4}), ([0-9][0-9]|[0-9]):([0-9][0-9])" 28 | result = re.match(pattern, s) 29 | if result: 30 | return True 31 | return False 32 | 33 | def findColon(s):#to know msg is valid or not 34 | n=len(s) 35 | c=0 36 | for i in range(n): 37 | if s[i]==":": 38 | c+=1 39 | return c #return no. of colon in a msg if 0 then this msg is not a valid msg 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | while 1: 49 | rd=cht.readline() 50 | if not rd:break 51 | 52 | total_msg_and_notification+=1 53 | if startsWithDate(rd):#to know msg is start with date or no not. 54 | 55 | splitLine=rd.split("-") 56 | dateTime=splitLine[0] 57 | 58 | date,time=dateTime.split(',') 59 | total_msg+=1 60 | 61 | if findColon(splitLine[1])>0:# to know this line is genuene msg or notification . 62 | total_valid_msg+=1 63 | authorMsg=splitLine[1].split(":") 64 | 65 | 66 | author= authorMsg[0][:15]+".." 67 | msg=authorMsg[1::] 68 | 69 | list_of_date_time_author_msg.append([date,time,author,msg]) 70 | 71 | else: 72 | list_of_notification.append(splitLine[1])#collect all notification such as: some add someone,someone join this group via link etc. 73 | 74 | 75 | 76 | 77 | 78 | print("\n\nTotal msg-",total_msg,"\nTotal valid msg-",total_valid_msg,"\ntotal_msg_and_notification",total_msg_and_notification) 79 | 80 | df=pd.DataFrame(list_of_date_time_author_msg,columns=["Date","Time","GroupMember","Message"]) 81 | 82 | l=dict(df['GroupMember'].value_counts()) 83 | xval=[] 84 | yval=[] 85 | for x,y in l.items(): 86 | xval.append(x) 87 | yval.append(y) 88 | 89 | def showAll(): 90 | 91 | plt.figure(figsize=(len(l)*0.25,10)) 92 | plt.bar(xval,yval,width=0.8) 93 | 94 | plt.title("Group: "+title1) 95 | plt.xlabel("Group Members") 96 | plt.ylabel("Number of messages") 97 | plt.xticks(xval,rotation=90) 98 | 99 | 100 | showAll() 101 | c3=0 102 | def autolabel(x,y): 103 | global c3 104 | for i in range(len(x)): 105 | 106 | plt.text(x[i],y[i]+5,str(y[i]),ha='center',rotation=90,color='red') 107 | c3+=y[i] 108 | autolabel(xval,yval) 109 | plt.text(len(l)-len(l)//2,len(l), 'Total Active Members: '+str(len(l))+", Total Message-"+str(c3),color='red') 110 | 111 | plt.show() 112 | #plt.savefig('test.png') 113 | -------------------------------------------------------------------------------- /image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subahanii/Whatsapp-Chat-Analyzer/87f4f40c89c1fdc06550d43100e433de8a4415f8/image1.png --------------------------------------------------------------------------------