import os
import shutil
import xlrd
excel_path = r"D:\指标.xlsx"
indicator_path = r"D:\IDX_V17"
destination_path = r"D:\IDX"
# 打开excel表格
excel_wb = xlrd.open_workbook(excel_path)
# 打开第一个sheet页
sheet1 = excel_wb.sheet_by_index(0)
# 行数减1,行数根据有值的行来确定
rowNum = sheet1.nrows - 1
idx_version = {}
for i in range(1, rowNum+1):
print(i, sheet1.cell(i, 5).value)
idx_version[sheet1.cell(i, 5).value + '.py'] = sheet1.cell(i, 9).value
print(idx_version)
# indicator = open(indicator_path, mode='r', encoding='utf-8')
versionPath = ""
# 遍历文件夹
for item in os.listdir(indicator_path):
version = idx_version.get(item)
if version == "基础版":
versionPath = "Basic"
elif version == "标准版":
versionPath = "Standard"
elif version == "高级版":
versionPath = "Advanced"
dest_path = os.path.join(destination_path, versionPath)
src_path = os.path.join(indicator_path, item)
# copy文件
res = shutil.copy(src_path, dest_path)
print("dest_path:" + dest_path)
print("src_path:" + src_path)
print("res:" + res)
print(item)