You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.6 KiB
45 lines
1.6 KiB
"""
|
|
创建示例Excel文件
|
|
"""
|
|
import pandas as pd
|
|
from pathlib import Path
|
|
|
|
def create_sample_excel():
|
|
"""创建示例Excel文件"""
|
|
# 创建data目录
|
|
data_dir = Path("data")
|
|
data_dir.mkdir(exist_ok=True)
|
|
|
|
# 示例数据
|
|
sample_data = {
|
|
'学号': [
|
|
'2021001', '2021002', '2021003', '2021004', '2021005',
|
|
'2021006', '2021007', '2021008', '2021009', '2021010',
|
|
'2021011', '2021012', '2021013', '2021014', '2021015',
|
|
'2021016', '2021017', '2021018', '2021019', '2021020'
|
|
],
|
|
'姓名': [
|
|
'张三', '李四', '王五', '赵六', '钱七',
|
|
'孙八', '周九', '吴十', '郑一', '王二',
|
|
'刘三', '陈四', '杨五', '黄六', '周七',
|
|
'吴八', '徐九', '孙十', '马一', '朱二'
|
|
],
|
|
'专业': [
|
|
'软件工程', '软件工程', '计算机科学', '计算机科学', '数据科学',
|
|
'软件工程', '数据科学', '软件工程', '计算机科学', '数据科学',
|
|
'软件工程', '计算机科学', '数据科学', '软件工程', '计算机科学',
|
|
'数据科学', '软件工程', '计算机科学', '数据科学', '软件工程'
|
|
]
|
|
}
|
|
|
|
df = pd.DataFrame(sample_data)
|
|
output_path = data_dir / "students_template.xlsx"
|
|
df.to_excel(output_path, index=False, engine='openpyxl')
|
|
|
|
print(f"示例Excel文件已创建: {output_path}")
|
|
print(f"包含 {len(sample_data['学号'])} 条学生记录")
|
|
|
|
if __name__ == "__main__":
|
|
create_sample_excel()
|
|
|