马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import xlrd
import xlsxwriter
path1 = r"C:\Users\Administrator\Desktop\bat\12309\化学优秀.xlsx"
path2 = r"C:\Users\Administrator\Desktop\bat\12309\历史优秀.xlsx"
path3 = r"C:\Users\Administrator\Desktop\bat\12309\数学优秀.xlsx"
path4 = r"C:\Users\Administrator\Desktop\bat\12309\物理优秀.xlsx"
path5 = r"C:\Users\Administrator\Desktop\bat\12309\英语优秀.xlsx"
path6 = r"C:\Users\Administrator\Desktop\bat\12309\语文优秀.xlsx"
path7 = r"C:\Users\Administrator\Desktop\bat\12309\政治优秀.xlsx"
path8 = r"C:\Users\Administrator\Desktop\bat\12309\优秀.xlsx"
source_xls = [path1,path2,path3,path4,path5,path6,path7]
target_xls = path8
# 读取数据
data = []
for i in source_xls:
wb = xlrd.open_workbook(i)
for sheet in wb.sheets():
for rownum in range(sheet.nrows):
rownum = rownum + 1
data.append(sheet.row_values(rownum))
print(data)
# 写入数据
workbook = xlsxwriter.Workbook(target_xls)
worksheet = workbook.add_worksheet()
font = workbook.add_format({"font_size":14})
for i in range(len(data)):
for j in range(len(data[i])):
worksheet.write(i, j, data[i][j], font)
# 关闭文件流
workbook.close()
上面是代码
Chinese Maths English Physics Chemistry Politics History
0 0.93 0.97 0.97 0.95 0.98 0.88 0.95
1 0.9 1 0.92 0.92 0.97 0.9 0.91
2 0.93 0.89 0.91 0.92 0.97 0.88 0.91
3 0.9 0.92 1 1 0.93 0.9 0.93
4 0.87 0.84 0.95 0.79 0.94 1 0.91
5 0.84 0.99 0.87 0.98 0.96 0.92 0.93
7 0.99 0.87 0.78 0.92 0.93 0.85 0.93
8 1 0.73 0.78 0.94 1 0.9 1
Chinese Maths English Physics Chemistry Politics History
0 0.93 0.97 0.97 0.95 0.98 0.88 0.95
1 0.9 1 0.92 0.92 0.97 0.9 0.91
2 0.93 0.89 0.91 0.92 0.97 0.88 0.91
3 0.9 0.92 1 1 0.93 0.9 0.93
4 0.87 0.84 0.95 0.79 0.94 1 0.91
5 0.84 0.99 0.87 0.98 0.96 0.92 0.93
6 0.89 0.91 0.91 0.71 0.85 0.88 0.91
7 0.99 0.87 0.78 0.92 0.93 0.85 0.93
8 1 0.73 0.78 0.94 1 0.9 1
11 0.87 0.91 0.75 0.7 0.81 0.7 0.93
13 0.75 0.65 0.63 0.51 0.53 0.62 0.91
Chinese Maths English Physics Chemistry Politics History
0 0.93 0.97 0.97 0.95 0.98 0.88 0.95
1 0.9 1 0.92 0.92 0.97 0.9 0.91
上面是出来的效果,第一行的索引 可以去掉吗, 列名也是多次出现,可以把列名去掉吗,谢谢
建议看下pandas,contact合并不用考虑这个麻烦,可以看下下图示意
|