目录
1、从腾讯问卷导出CSV数据
2、Python
1、从腾讯问卷导出CSV数据
?将全部打卡人数的信息,放入benkeshen文件夹,一行一个名字
运行python程序,得出结果
2、Python
import csv
time = r"2022/3/22"
# 读取第一个文件name
with open(r'C:\Users\14193\Desktop\benkesheng.txt', 'r', encoding='utf-8') as f1:
name = f1.read()
# 将字符串name 切片成 list
name = name.split()
print(f"人数:\t{len(name)}")
# 读取第二个文件
with open(r'C:\Users\14193\Desktop\1.csv', 'r', encoding='utf-8') as f2:
reader = csv.reader(f2)
# 略过第一行
next(reader)
# 逐行遍历剩下的每行数据
for row in reader:
# 对比所需找的日期 将出现的name删除
if time in row[2] and row[11] in name:
name.remove(row[11])
# 直接在控制台输出结果
print(f"未打卡:\t{name}")
# 将结果输出到文件中
with open(r'C:\Users\14193\Desktop\result.txt', 'w', encoding='utf-8') as f3:
# 逐行遍历name
for row in name:
f3.write(row)
f3.write("\n")
|