Index: trunk/tools/editor_trends/etl/store.py |
— | — | @@ -117,13 +117,12 @@ |
118 | 118 | #print line.encode('utf-8') |
119 | 119 | line = line.split('\t') |
120 | 120 | data = {} |
121 | | - for l in line: |
122 | | - #print l.encode('utf-8') |
123 | | - try: |
124 | | - key, value = l.split('=') |
125 | | - except ValueError, error: |
126 | | - print l.encode('utf-8') |
| 121 | + x, y = 0, 1 |
| 122 | + while y < len(line): |
| 123 | + key, value = line[x], line[y] |
127 | 124 | data[key] = value |
| 125 | + x += 2 |
| 126 | + y += 2 |
128 | 127 | collection.insert(data) |
129 | 128 | fh.close() |
130 | 129 | print 'Done...' |
Index: trunk/tools/editor_trends/etl/transformer.py |
— | — | @@ -173,12 +173,14 @@ |
174 | 174 | for year in edits: |
175 | 175 | for edit in edits[year]: |
176 | 176 | month = edit['date'].month |
177 | | - dc[year][month].setdefault('added', 0) |
178 | | - dc[year][month].setdefault('removed', 0) |
| 177 | + ns = edit['ns'] |
| 178 | + dc[year][month].setdefault(ns, {}) |
| 179 | + dc[year][month][ns].setdefault('added', 0) |
| 180 | + dc[year][month][ns].setdefault('removed', 0) |
179 | 181 | if edit['delta'] < 0: |
180 | | - dc[year][month]['removed'] += edit['delta'] |
| 182 | + dc[year][month][ns]['removed'] += edit['delta'] |
181 | 183 | elif edit['delta'] > 0: |
182 | | - dc[year][month]['added'] += edit['delta'] |
| 184 | + dc[year][month][ns]['added'] += edit['delta'] |
183 | 185 | return dc |
184 | 186 | |
185 | 187 | |