-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgo.py
More file actions
35 lines (32 loc) · 830 Bytes
/
go.py
File metadata and controls
35 lines (32 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import read
from conf import handler_dom, CITY
import json
import csv
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from mongokit import Connection
conn = Connection()
party = conn.party.party
def view(r):
print json.dumps(r, ensure_ascii=False, indent=4)
flag = 0
mycsv = csv.writer(sys.stdout)
# for dom in read.analyse_data():
# for r in handler_dom(dom):
# r['location'] = CITY
# r['type'] = 'party'
# if not party.find_one({'_id': r['_id']}):
# party.insert(r)
# else:
# print r['title']
# view(r)
# if not flag:
# mycsv.writerow(r.keys())
# flag = 1
# mycsv.writerow(r.values())
for r in party.find():
if not flag:
mycsv.writerow(r.keys())
flag = 1
mycsv.writerow(r.values())