def main(): currentdir = get_main_dir() + '/' print 'currentdir:', currentdir os.chdir(currentdir) patterns = ['*.xml'] if protocol_filename != '*': patterns = protocol_filename.split(',') for root, dirs, files in os.walk(protocol_dir, True): for name in files: for pattern in patterns: if fnmatch.fnmatch(name,pattern): currentFileName= os.path.splitext(name)[0] excelFile = os.path.join(root,name) print name parse_xml(excelFile, currentdir, currentFileName) break
root = doc.documentElement user_nodes = get_nodes_by_name(root, 'record') for node in user_nodes: rowIndex += 1 rowCellDict = {} processRow(rowIndex, node, rowCellDict) if rowCellDict: sheetRowList.append(rowCellDict) packDataList(sheetRowList) if __name__ == '__main__': global currentdir global currentFileName currentdir = get_main_dir() + '/' print 'currentdir:', currentdir os.chdir(currentdir) patterns = ['*.xml'] if xml_filename != '*': patterns = xml_filename.split(',') for root, dirs, files in os.walk(xml_dir, True): for name in files: for pattern in patterns: if fnmatch.fnmatch(name, pattern): currentFileName = os.path.splitext(name)[0] excelFile = os.path.join(root, name) print excelFile parseExcel(excelFile) break raw_input('input enter...>')
for row in ws.iter_rows(): # it brings a new method: iter_rows() rowIndex += 1 rowCellDict = {} processRow(rowIndex, row,rowCellDict) if rowCellDict: sheetRowList.append(rowCellDict) packDataList(sheetRowList) except Exception,e: print e if __name__ == '__main__': global currentdir global currentFileName try: currentdir = get_main_dir()+'/' print 'currentdir:', currentdir os.chdir(currentdir) patterns = ['*.xls', '*.xlsx'] if excel_filename != '*': patterns = excel_filename.split(',') for root, dirs, files in os.walk(excel_dir, True): for name in files: for pattern in patterns: if fnmatch.fnmatch(name,pattern): currentFileName= os.path.splitext(name)[0] excelFile = os.path.join(root,name) print excelFile parseExcel(excelFile) break except Exception,e: