From b7b619ba0bdf001b9d2ee0a7c7820098df3daccb Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Thu, 19 Mar 2015 20:56:57 +0100 Subject: [PATCH] Improve duplicate handling --- getter.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/getter.py b/getter.py index 80d54d7..9f3aa34 100755 --- a/getter.py +++ b/getter.py @@ -70,16 +70,18 @@ while True: print "Error in " + str(twid) print e continue - - words = text.split(" ") - for word in words: - if word[0] == "@" and (not user == word[1:]) and (not sender == word[1:]): - wordlist += word - - wordlist = list(set(wordlist)) - for word in wordlist: - comment += word + " " - + + words = text.split(" ") + for word in words: + wordlist += word + + wordlist = list(set(wordlist)) + try: + wordlist.remove(user) + wordlist.remove(sender) + except ValueError: + pass + cur.execute("INSERT INTO tweets VALUES(%i,'%s','%s','%s',0)" % (twid,date.strftime("%Y-%m-%dT%H:%M:%S"),sender,comment.strip())) sql_conn.commit()