今天就业处来打电话,我才想起来还没有帮他们把问卷的数据整理😂;所以下午利用Python整理的一下:
原始数据
1,14,201800xx0040,1.入学前家庭居住地(),1,E.乡镇村,信息技术学院,计算机类,2018
2,14,201800xx0040,2.学习成绩排名(),1,B.班级前20%—40%,信息技术学院,计算机类,2018
3,14,201800xx0040,3.你是否有职业发展规划(),1,B.有,有大致的规划,信息技术学院,计算机类,2018
4,14,201800xx0040,4.你在什么时候开始考虑自己的职业生涯规划(),1,C.大二,信息技术学院,计算机类,2018
5,14,201800xx0040,5.你是否有明确的职业目标(),1,B.比较明确,信息技术学院,计算机类,2018
6,14,201800xx0040,6.你在职业生涯规划中遇到的问题有()(可多选),2,B.对职业、行业信息缺乏了解,信息技术学院,计算机类,2018
7,14,201800xx0040,7.你认为对职业规划有帮助的因素有()(可多选),2,A.学校的职业生涯规划等相关课程,信息技术学院,计算机类,2018
8,14,201800xx0040,7.你认为对职业规划有帮助的因素有()(可多选),2,C.职业规划与就业指导相关交流会和讲座,信息技术学院,计算机类,2018
9,14,201800xx0040,7.你认为对职业规划有帮助的因素有()(可多选),2,E.相关书籍和网站,信息技术学院,计算机类,2018
10,14,201800xx0040,8.你认为影响就业及职业发展的能力因素有哪些()(可多选),2,A.沟通能力,信息技术学院,计算机类,2018
11,14,201800xx0040,8.你认为影响就业及职业发展的能力因素有哪些()(可多选),2,B.学习能力,信息技术学院,计算机类,2018
12,14,201800xx0040,8.你认为影响就业及职业发展的能力因素有哪些()(可多选),2,D.团队协作能力,信息技术学院,计算机类,2018
13,14,201800xx0040,8.你认为影响就业及职业发展的能力因素有哪些()(可多选),2,E.执行力,信息技术学院,计算机类,2018
14,14,201800xx0040,8.你认为影响就业及职业发展的能力因素有哪些()(可多选),2,H.有责任感,信息技术学院,计算机类,2018
15,14,201800xx0040,8.你认为影响就业及职业发展的能力因素有哪些()(可多选),2,K.实习实践经历,信息技术学院,计算机类,2018
16,14,201800xx0040,9.你认为在校期间通过何种渠道能获得上述能力()(可多选),2,A.课堂教学,信息技术学院,计算机类,2018
17,14,201800xx0040,9.你认为在校期间通过何种渠道能获得上述能力()(可多选),2,D.社会实践,信息技术学院,计算机类,2018
18,14,201800xx0040,9.你认为在校期间通过何种渠道能获得上述能力()(可多选),2,E.专业实习,信息技术学院,计算机类,2018
每一个人对每一个问题的每一个答案是一条记录。
目标数据
学号,姓名,学院,专业,班级,入学时间,1E,1D,1C,1B,1A,2D,2C,2B,2A,3D,3C,3B,3A,4F,4E,4D,4C,4B,4A,5D,5C,5B,5A,6E,6D,6C,6B,6A,7G,7F,7E,7D,7C,7B,7A,8K,8J,8I,8H,8G,8F,8E,8D,8C,8B,8A,9J,9I,9H,9G,9F,9E,9D,9C,9B,9A,10G,10F,10E,10D,10C,10B,10A,11E,11D,11C,11B,11A,12I,12H,12G,12F,12E,12D,12C,12B,12A,13J,13I,13H,13G,13F,13E,13D,13C,13B,13A,14F,14E,14D,14C,14B,14A,15E,15D,15C,15B,15A,16F,16E,16D,16C,16B,16A,17H,17G,17F,17E,17D,17C,17B,17A,18H,18G,18F,18E,18D,18C,18B,18A,19E,19D,19C,19B,19A,20J,20I,20H,20G,20F,20E,20D,20C,20B,20A,21E,21D,21C,21B,21A,22G,22F,22E,22D,22C,22B,22A,23I,23H,23G,23F,23E,23D,23C,23B,23A,24F,24E,24D,24C,24B,24A,25M,25L,25K,25J,25I,25H,25G,25F,25E,25D,25C,25B,25A,26E,26D,26C,26B,26A,27H,27G,27F,27E,27D,27C,27B,27A,28D,28C,28B,28A,29G,29F,29E,29D,29C,29B,29A,30E,30D,30C,30B,30A,31C,31B,31A,32H,32G,32F,32E,32D,32C,32B,32A,33G,33H,33G,33F,33E,33D,33C,33B,33A
2018xxxx840,XXXXX,信息技术学院,计算机类,计算机类18_3,2018,1,1,,,,,,1,,,,1,,,,,1,,,,,1,,,,,1,,,,1,1,1,1,1,1,,,1,,,1,1,,1,1,,,,,,1,1,1,1,1,,,1,1,1,1,1,,1,1,1,1,,,1,1,1,1,1,,,,,,1,1,,1,1,,1,,1,1,1,1,1,,,,1,,,,,,,1,,,1,,,,,,,,,,,1,,,,,,1,,,,,1,1,1,,1,1,1,1,,,,,,,,1,,1,1,,,1,,,1,1,,1,,,1,,1,,,,,,,1,,1,1,1,1,,,1,,,,,1,,,,,,,,1,,,,1,,,,,,,1,,,,,,1,,,1,1,1,,1,1,1,,,,,,,1,1,1
2017xxxxx945,XXXX,商学院,经济学,经济17_1,2017,,,,,1,,,1,,,1,,,,1,,,,,,1,,,,1,1,1,1,,,,,1,1,1,,,,,1,,1,1,1,1,1,1,,1,1,1,1,,,1,,,,,,1,1,,,,,1,,,,,,,,1,,,,,,1,,,,,,,,1,,,,1,,1,,,,,,,,,1,,,,,,1,,,,,,,,,,1,1,,,,,,,,,,,,,1,1,,,,,1,,,1,1,1,1,,,,,,,1,,,1,,,,,,1,,,,,,1,1,1,1,,1,,1,1,,,,,,,,,,,,1,1,,,,1,1,,1,1,1,,,,,,1,,1,,,1,1,1,,,1,1,,,,,,1,1,1,1
即每一个人对所有问题的所有答案是一条记录。
代码
# -*- coding: utf-8 -*-
import csv
import os
headers = ['学号','姓名','学院','专业','班级','入学时间','1E', '1D', '1C', '1B', '1A', '2D', '2C', '2B', '2A', '3D', '3C', '3B', '3A', '4F', '4E', '4D', '4C', '4B', '4A', '5D', '5C', '5B', '5A', '6E', '6D', '6C', '6B', '6A', '7G', '7F', '7E', '7D', '7C', '7B', '7A', '8K', '8J', '8I', '8H', '8G', '8F', '8E', '8D', '8C', '8B', '8A', '9J', '9I', '9H', '9G', '9F', '9E', '9D', '9C', '9B', '9A', '10G', '10F', '10E', '10D', '10C', '10B', '10A', '11E', '11D', '11C', '11B', '11A', '12I', '12H', '12G', '12F', '12E', '12D', '12C', '12B', '12A', '13J', '13I', '13H', '13G', '13F', '13E', '13D', '13C', '13B', '13A', '14F', '14E', '14D', '14C', '14B', '14A', '15E', '15D', '15C', '15B', '15A', '16F', '16E', '16D', '16C', '16B', '16A', '17H', '17G', '17F', '17E', '17D', '17C', '17B', '17A', '18H', '18G', '18F', '18E', '18D', '18C', '18B', '18A', '19E', '19D', '19C', '19B', '19A', '20J', '20I', '20H', '20G', '20F', '20E', '20D', '20C', '20B', '20A', '21E', '21D', '21C', '21B', '21A', '22G', '22F', '22E', '22D', '22C', '22B', '22A', '23I', '23H', '23G', '23F', '23E', '23D', '23C', '23B', '23A', '24F', '24E', '24D', '24C', '24B', '24A', '25M', '25L', '25K', '25J', '25I', '25H', '25G', '25F', '25E', '25D', '25C', '25B', '25A', '26E', '26D', '26C', '26B', '26A', '27H', '27G', '27F', '27E', '27D', '27C', '27B', '27A', '28D', '28C', '28B', '28A', '29G', '29F', '29E', '29D', '29C', '29B', '29A', '30E', '30D', '30C', '30B', '30A', '31C', '31B', '31A', '32H', '32G', '32F', '32E', '32D', '32C', '32B', '32A', '33G', '33H', '33G', '33F', '33E', '33D', '33C', '33B', '33A']
domain_ner_dict = {}
filePath = os.getcwd()
with open('C:/Users/SkyFly/Desktop/userniandujuandaan.txt','r',encoding="utf-8") as csvfile:
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
domain_ner_dict.setdefault(str(row[2]),[]).append(str(row[3]).split(".")[0]+row[5][0])
with open('C:/Users/SkyFly/Desktop/student_info.txt','r',encoding="utf-8") as stu:
reader2 = csv.reader(stu)
for row in reader2:
if row[0] in domain_ner_dict:
domain_ner_dict.setdefault(row[0],[]).insert(0,row[5])
domain_ner_dict.setdefault(row[0],[]).insert(0,row[4])
domain_ner_dict.setdefault(row[0],[]).insert(0,row[3])
domain_ner_dict.setdefault(row[0],[]).insert(0,row[2])
domain_ner_dict.setdefault(row[0],[]).insert(0,row[1])
domain_answer_list = []
for key in domain_ner_dict.keys():
domain_answer = domain_ner_dict.get(key)
domain_dict = {}
domain_dict['学号'] = key
domain_dict['姓名'] = domain_answer[0]
domain_dict['学院'] = domain_answer[1]
domain_dict['专业'] = domain_answer[2]
domain_dict['班级'] = domain_answer[3]
domain_dict['入学时间'] = domain_answer[4]
for index in range(5,len(domain_answer)):
domain_dict[str(domain_answer[index])] = 1
domain_answer_list.append(domain_dict)
print(domain_answer_list)
with open('./test.csv','w',newline='') as fr:
f_csv = csv.DictWriter(fr,headers)
f_csv.writeheader()
f_csv.writerows(domain_answer_list)