File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 33import MySQLdb
44import os
55import logging
6+ import shutil
67import sys
78
89
@@ -12,17 +13,21 @@ def main(path):
1213 """
1314 files = os .listdir (path )
1415 for file in files :
15- save_file (path + '/' + file )
16+ save_file (path + '/' + file , file )
1617 print (file )
17- logging .info (file )
1818
1919
20- def save_file (file ):
20+ def save_file (file , filename ):
2121 """
2222 打开excel文件
2323 """
24- book = xlrd .open_workbook (file )
25- sheet = book .sheet_by_index (0 )
24+ try :
25+ book = xlrd .open_workbook (file )
26+ sheet = book .sheet_by_index (0 )
27+ except Exception as e :
28+ logging .info ('错误:{0} 文件:{1}' .format (e , file ))
29+ shutil .copy2 (file , './error' + filename )
30+ return False
2631 row_nums = sheet .nrows
2732 col_nums = sheet .ncols
2833
You can’t perform that action at this time.
0 commit comments