Created
December 25, 2011 10:55
Revisions
-
mutsuda created this gist
Dec 25, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ # Position where the first character of a name is found in each line start = 19 # File containing the watsapp conversation file_name = "watext.txt" def get_name(line): end = line.find(":", start) return line[start:end] def get_text(line): end = line.find(":", start) return line[end+2:len(line)] def check_special(line): if ((line.find("joined") != -1) or (line.find("changed subject") != -1)): return 1 else: return 0 print "Processing file..." now = datetime.datetime.now() whatsapp = open(file_name, "r") for line in whatsapp: if not check_special(line) and (re.search("../../.. ..:..:..:", line)): if not os.path.exists("words/"+get_name(line)): os.makedirs("words/"+get_name(line)) file = open("words/"+get_name(line)+"/"+str(now), "a") file.write(get_text(line)) print "Done! Go to the words folder!"