Skip to content

Commit 017b761

Browse files
author
minseok0809
committed
feat: school automation
1 parent 251571d commit 017b761

File tree

2 files changed

+163
-819
lines changed

2 files changed

+163
-819
lines changed

school-automation/exam_score_dataframe_to_txt_converter.ipynb

+51-8
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,51 @@
4040
},
4141
{
4242
"cell_type": "code",
43-
"execution_count": 2,
43+
"execution_count": 11,
4444
"metadata": {},
4545
"outputs": [],
4646
"source": [
47-
"midterm_exam_df = pd.read_excel(\"AI100 인공지능개론 중간고사 채점 (파이썬).xlsx\", engine='openpyxl')\n",
48-
"final_exam_df = pd.read_excel(\"AI100 인공지능개론 기말고사 채점 (파이썬).xlsx\", engine='openpyxl')"
47+
"midterm_exam_df = pd.read_excel(\"강의 1 중간고사 채점 (파이썬).xlsx\", engine='openpyxl')\n",
48+
"final_exam_df = pd.read_excel(\"강의 1 기말고사 채점 (파이썬).xlsx\", engine='openpyxl')\n",
49+
"total_exam_df = pd.read_excel(\"강의 1 총점 (파이썬).xlsx\", engine='openpyxl')"
4950
]
5051
},
5152
{
5253
"cell_type": "code",
53-
"execution_count": 14,
54+
"execution_count": 23,
55+
"metadata": {},
56+
"outputs": [],
57+
"source": [
58+
"def total_score_txt(exam_score_dataframe_midterm, exam_score_dataframe_final, exam_score_dataframe_total, txt_file_path):\n",
59+
" student_num = len(exam_score_dataframe_midterm)\n",
60+
" \n",
61+
" with open(txt_file_path, \"w\") as f:\n",
62+
" for i in range(student_num):\n",
63+
" student_info_midterm = list(exam_score_dataframe_midterm.loc[i, :])\n",
64+
" student_info_final = list(exam_score_dataframe_final.loc[i, :])\n",
65+
" student_info_total = list(exam_score_dataframe_total.loc[i, :])\n",
66+
" student_infos = [student_info_midterm, student_info_final, student_info_total]\n",
67+
" for num, student_info in enumerate(student_infos):\n",
68+
" if num == 0: columns = list(exam_score_dataframe_midterm.columns) \n",
69+
" elif num == 1: columns = list(exam_score_dataframe_final.columns)\n",
70+
" elif num == 2: columns = list(exam_score_dataframe_total.columns)\n",
71+
" \n",
72+
" for idx, (j, k) in enumerate(zip(columns, student_info)):\n",
73+
" if num == 0 and idx == 1: f.write('중간고사:\\n') \n",
74+
" elif num == 1 and idx == 2: f.write('기말고사:\\n') \n",
75+
" elif num == 2 and idx == 2: f.write('총점:\\n') \n",
76+
"\n",
77+
" if num == 2 and idx == 6: \n",
78+
" f.write('{}: {} (10점 만점) \\n'.format(j, k))\n",
79+
" else:\n",
80+
" f.write('{}: {}\\n'.format(j, k)) \n",
81+
" f.write('\\n')\n",
82+
" f.close()"
83+
]
84+
},
85+
{
86+
"cell_type": "code",
87+
"execution_count": 7,
5488
"metadata": {},
5589
"outputs": [],
5690
"source": [
@@ -71,20 +105,29 @@
71105
},
72106
{
73107
"cell_type": "code",
74-
"execution_count": 16,
108+
"execution_count": 4,
109+
"metadata": {},
110+
"outputs": [],
111+
"source": [
112+
"score_txt(midterm_exam_df, \"강의 1 중간고사 채점 (파이썬).txt\")\n",
113+
"score_txt(final_exam_df, \"강의 1 기말고사 채점 (파이썬).txt\")"
114+
]
115+
},
116+
{
117+
"cell_type": "code",
118+
"execution_count": 24,
75119
"metadata": {},
76120
"outputs": [],
77121
"source": [
78-
"score_txt(midterm_exam_df, \"AI100 인공지능개론 중간고사 채점 (파이썬).txt\")\n",
79-
"score_txt(final_exam_df, \"AI100 인공지능개론 기말고사 채점 (파이썬).txt\")"
122+
"total_score_txt(midterm_exam_df, final_exam_df, total_exam_df, \"강의 1 총점 (파이썬).txt\")"
80123
]
81124
}
82125
],
83126
"metadata": {
84127
"kernelspec": {
85128
"display_name": "exercise",
86129
"language": "python",
87-
"name": "python3"
130+
"name": "exercise"
88131
},
89132
"language_info": {
90133
"codemirror_mode": {

0 commit comments

Comments
 (0)