Skip to content

Instantly share code, notes, and snippets.

@keskarnitish
Last active January 14, 2017 14:13
Show Gist options
  • Save keskarnitish/8763635 to your computer and use it in GitHub Desktop.
Save keskarnitish/8763635 to your computer and use it in GitHub Desktop.
Clean WhatsApp Generated Text File for Image Cloud Scripts
#Extremely simple script to cleanup the conversation data that WhatsApp generates
#You can email yourself the conversation from your WhatsApp mobile application, run this script and use any popular word cloud generator like http://www.wordle.net/create.
#TO DO: Include code to create wordcloud as well. Possibly https://github.com/atizo/PyTagCloud or https://github.com/amueller/word_cloud
#Usage: python WhatsAppCleaner.py Foo.txt
from sys import argv
script, filename = argv
f = open(filename,'r')
for line in f:
try:
temp = line.split(': ')[1];
if('Media' not in temp): # If any form of media is sent, WhatsApp prints "<Media Omitted>". Getting rid of this. TO DO: Improve this functionality.
print temp
except:
print " "
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment