First we need to download WhatsApp file from mobile device By clicking on group chat more button than export chat. you have to import chat without media,then open file in python using statement as shown below.

Code to read WhatsApp chat file using python:

#By 'with' Statement
with open('WhatsApp Chat.txt',encoding="utf-8") as chat:
wchat=chat.readlines()
print(wchat)
print(type(wchat))
# it will give list as output.
# By 'open' statement
w = open('WhatsApp Chat.txt', 'r', encoding='utf-8')
wchat=w.read()
print(type(wchat))
it will give string as output.

By SC

Leave a Reply

Your email address will not be published. Required fields are marked *