script/rest/getscreennames.py
changeset 9 bb44692e09ee
child 891 8628c590f608
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/script/rest/getscreennames.py	Tue Jan 11 11:17:17 2011 +0100
@@ -0,0 +1,36 @@
+from sqlite3 import *
+import datetime, time
+import email.utils
+from optparse import OptionParser
+import os.path
+import os
+import sys
+import simplejson
+import re
+
+if __name__ == "__main__" :
+
+    parser = OptionParser()
+
+    (options, args) = parser.parse_args()
+    
+    conn = connect(args[0])
+    conn.row_factory = Row
+    curs = conn.cursor()
+    
+    names = {}
+    
+    curs.execute("select tt.text as text from tweet_tweet as tt left join tweet_user as tu on tt.user = tu.rowid where tt.text like \"%ENMI09%\" order by tt.created_at_ts asc;")
+    
+    regexp = re.compile("\@(\w+)")
+    
+    for row in curs:
+        text = row["text"]
+        for m in regexp.finditer(text):
+            names[m.group(1)]=m.group(1)
+    
+    
+    print repr(names.keys())
+    print repr(len(names.keys()))
+            
+