python 读取excel 写excel
读取如下格式的excel
import pandas as pd
from pandas import DataFrame
df = pd.read_excel('WMR统计名单2021.xls')
height,width = df.shape
print(height,width,type(df))
print(df.loc[0]['学员姓名'])
#for i in range(height):
a = [['考点名称:','123'],
['姓 名:','wu'],
['准考证号:','1233'],
['身份证号:','13333'],
['',''],
['考试时间','8月14日 上午09:30~11:00'],
['考试科目',''],
['腾讯会议ID号','749 645 928'],
['会议密码','123456']]
str1 = "sheet"
writer = pd.ExcelWriter('1.xlsx')
for i in range(height):
a[0][1] = df.loc[i]['所属校区']
a[1][1] = df.loc[i]['学员姓名']
a[2][1] = df.loc[i]['准考证号']
a[3][1] = df.loc[i]['证件号码']
a[6][1] = df.loc[i]['参赛项目']
str2 = str1 + str(i)
df1 = pd.DataFrame(a)
df1.to_excel(writer, sheet_name=str2,index =False)
writer.save()
结果如下:
``