12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #coding=utf-8
- '''
- Created on 2016年6月13日
- @author: uas
- '''
- from pymongo.mongo_client import MongoClient
- from util_common import Constant
- import csv
- cli=MongoClient(Constant.MONGODB_URL)
- db=cli.spider
-
-
- rows_cmp=db.component_temp_0607.find({'cmp_kiid':None})
- rows_original=db.component_original.find({},{'_id':False,'code':True,'lastkind':True})
- with open('newtranslate.csv',newline='') as csvfile:
- reader=csv.reader(csvfile,delimiter=',')
- relation_dict=dict()
- for index,row in enumerate(reader):
- if index==0:
- continue
- relation_dict[row[1]]=row[2]
-
-
- rows_original_list=list()
- for r in rows_original:
- rows_original_list.append(r)
- print(len(rows_original_list))
-
-
-
- for index,r in enumerate(rows_cmp):
- if rows_original_list[r['cmp_id']-1]['code']==r['cmp_code']:
- print(index)
- uuid=relation_dict.get(rows_original_list[r['cmp_id']-1]['lastkind'])
- print(rows_original_list[r['cmp_id']-1]['lastkind']+''+str(uuid))
- if uuid is not None:
- db.component_temp_0607.update({'_id':r['_id']},{'$set':{'cmp_kiid':uuid}})
|