http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88326

Revision: 88326
Author:   diederik
Date:     2011-05-17 17:18:37 +0000 (Tue, 17 May 2011)
Log Message:
-----------
Adhoc queries, augment dataset with user registration date

Added Paths:
-----------
    trunk/tools/editor_trends/etl/adhoc/
    trunk/tools/editor_trends/etl/adhoc/user_registration_date.py

Added: trunk/tools/editor_trends/etl/adhoc/user_registration_date.py
===================================================================
--- trunk/tools/editor_trends/etl/adhoc/user_registration_date.py               
                (rev 0)
+++ trunk/tools/editor_trends/etl/adhoc/user_registration_date.py       
2011-05-17 17:18:37 UTC (rev 88326)
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+'''
+Copyright (C) 2011 by Ryan Faulkner ([email protected])
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 2
+as published by the Free Software Foundation.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details, at
+http://www.fsf.org/licenses/gpl.html
+'''
+
+__author__ = '''\n'''.join(['Diederik van Liere ([email protected])', ])
+__email__ = 'dvanliere at gmail dot com'
+__date__ = '2011-04-20'
+__version__ = '0.1'
+
+import sys
+from datetime import datetime
+if '..' not in sys.path:
+    sys.path.append('../../')
+    
+from classes import storage
+
+location  = '/Users/diederik/Desktop/d_20110502.tsv'
+fh = open(location, 'r')
+db = storage.init_database('mongo', 'wikilytics', 'enwiki_editors_dataset')
+
+for i, line in enumerate(fh):
+    if i ==0:
+        continue
+    line = line.strip()
+    line = line.replace("'",'')
+    line = line.split('\t')
+    id =line[0]
+    id = int(id[:-1])
+    #date1=eval(line[1])
+    if line[1] == 'None':
+        continue
+    date = datetime.strptime(line[1][:8], '%Y%m%d')
+    db.update('id', id, {'reg_date': date})
+    
+
+fh.close()
\ No newline at end of file


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to