Skip to content

anshtiwatne/chat-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WhatsApp Chat Analyzer

Get interesting statistics on WhatsApp chats

Installation & Usage

Clone the repository and run the script or download the executable if on Windows

python wordlesolver.py

Enter path to chat file: .\chats\testchat.txt
Is the date formatted as day first?: n

Example

coming soon

How it Works

Given a chat file, the script scrapes the chat to create a dataframe based on which and statistics on the chat are generated.

def frame_data(path: str):
    """Scrapes Whatsapp chat export file and creates a dataframe"""

    with open(path, "r", encoding="UTF8") as file:
        # groups: date, time, meridiem, sender, message
        pattern = r"(\d*?/\d*?/\d*?), (\d*?:\d*?) ([Aa]|[Pp][Mm]) - (.*?): (.*)"
        data = pd.Series(file.read()).str.findall(pattern)[0]
    
    df = pd.DataFrame(columns=["timestamp", "user", "message"])
    for element in data:
        date, time, meridiem, sender, message = element
        time = f"{time} {meridiem}"
        if message in AUTOMATED_MESSAGES: message = ""
        timestamp = pd.to_datetime(f"{date} {time}", format=DT_FORMAT)
        df.loc[len(df)] = [timestamp, sender, message]

    return df

Screenshots

chat_stats user_stats

License

MIT

About

Get statistics on WhatsApp chats

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages