| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #coding=utf-8
- '''
- Created on 2016年7月29日
- @author: uas
- '''
- from util_common import Constant
- import csv
- from pymongo.mongo_client import MongoClient
-
-
- cli=MongoClient(Constant.MONGODB_URL)
- db=cli.spider
-
-
- result=db.panel_propertyvalue_0728.find()
- total_list=list()
- for index, r in enumerate(result):
- print(index)
- row_list=list()
- row_list.append(r['kind'])
- row_list.append(r['property'])
- row_list.append(r['detno'][-4:])
- if row_list not in total_list:
- total_list.append(row_list)
-
-
- with open('csv_test.csv','w',newline='')as csvfile:
-
- writer=csv.writer(csvfile)
- writer.writerow(['器件类目','器件属性','属性所属'])
- for index,r in enumerate(total_list):
- writer.writerow(r)
- # csvfile =open('csv_test.csv', 'wb')
- # writer = csv.writer(csvfile)
- # csv_out.writerow(['Domain:','Mail Server:','TLS:','# of Employees:','Verified:'])
- #
- # data = [
- # ('小河', '25', '1234567'),
- # ('小芳', '18', '789456')
- # ]
- # writer.writerows(data)
- #
- # csvfile.close()
|