forked from tanteng/learn-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestmongo.py
More file actions
31 lines (23 loc) · 721 Bytes
/
testmongo.py
File metadata and controls
31 lines (23 loc) · 721 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
# -*- coding:utf-8 -*-
from pymongo import MongoClient
import time
import re
import os
import gridfs
import sys
client = MongoClient('mongodb://192.168.6.212:27017/send_excel')
db = client.js_send_excel
fs = gridfs.GridFS(db)
files = fs.find()
time_start = time.clock()
print('总数:', files.count())
count = 0
for ffle in files:
filename = ffle.filename
m = re.match(r'发货订单', filename)
if m and filename.find('xls') > 0 and not os.path.isfile('./excel/' + filename):
with open('./excel2/' + filename, 'wb') as f1:
f1.write(ffle.read())
count += 1
print('执行时间{0}秒'.format(time.clock() - time_start))
print('本次更新{0}个文档'.format(count))