File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1-
21from pymongo import MongoClient
3- import datetime
2+ import gridfs
3+ import time
4+ import re
5+ import os
6+ import sys
47
5- client = MongoClient ('mongodb://tanteng:123456@localhost: 27017/' )
8+ client = MongoClient ('mongodb://192.168.1.22: 27017/excel ' )
69db = client .js_send_excel
10+ fs = gridfs .GridFS (db )
11+ files = fs .find ()
12+
13+ time_start = time .clock ()
14+ print ('总数:' , files .count ())
15+
16+ for ffle in files :
17+ filename = ffle .filename
18+ m = re .match (r'发货订单' , filename )
719
8- post = {"author" : "Xiaofeng" , "text" : "My first blog post!" ,
9- "tags" : ["mongodb" , "python" , "pymongo" ],}
20+ if m and filename .find ('.xls' ) > 0 and not os .path .isfile ('./excel/' + filename ):
21+ with open ('./excel/' + filename , 'wb' ) as f1 :
22+ f1 .write (ffle .read ())
1023
11- posts = db .posts
12- post_id = posts .insert_one (post ).inserted_id
13- print (post_id )
24+ print ('执行时间{0}秒' .format (time .clock () - time_start ))
You can’t perform that action at this time.
0 commit comments