修复 Bug: 文件选择索引;身份证转化为文本格式
parent
34bbfe236a
commit
c7a5318ed9
22
main.py
22
main.py
|
|
@ -1,21 +1,25 @@
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import time, datetime
|
import datetime
|
||||||
from math import floor
|
from math import floor
|
||||||
|
from copy import copy
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# Read & Process ID table
|
# Read & Process ID table
|
||||||
items = os.listdir(os.path.abspath('.'))
|
items = os.listdir(os.path.abspath('.'))
|
||||||
print("在当前目录共有以下文件:")
|
print("在当前目录共有以下文件:")
|
||||||
file_index = 0
|
file_index = 0
|
||||||
|
items_copy = copy(items)
|
||||||
for item in items:
|
for item in items:
|
||||||
if item != "main.py" and item != "main.exe":
|
if item != "main.py" and item != "main.exe" and item[0] != '.':
|
||||||
file_index += 1
|
file_index += 1
|
||||||
print(f"{file_index} - {item}")
|
print(f"{file_index} - {item}")
|
||||||
|
else:
|
||||||
|
items_copy.remove(item)
|
||||||
id_index = int(input("请选择身份证列表(输入数字后回车)"))
|
id_index = int(input("请选择身份证列表(输入数字后回车)"))
|
||||||
duty_index = int(input("请选择值班排班表(输入数字后回车)"))
|
duty_index = int(input("请选择值班排班表(输入数字后回车)"))
|
||||||
|
|
||||||
identities_path = r'./' + items[id_index - 1]
|
identities_path = r'./' + items_copy[id_index - 1]
|
||||||
duty_path = r'./' + items[duty_index - 1]
|
duty_path = r'./' + items_copy[duty_index - 1]
|
||||||
|
|
||||||
print("正在读取身份信息...")
|
print("正在读取身份信息...")
|
||||||
identities = pd.read_excel(identities_path, sheet_name= "Sheet1")
|
identities = pd.read_excel(identities_path, sheet_name= "Sheet1")
|
||||||
|
|
@ -31,7 +35,7 @@ print("读取完毕!")
|
||||||
|
|
||||||
# Read & Calculate Honor Hours
|
# Read & Calculate Honor Hours
|
||||||
print("正在读取值班信息...")
|
print("正在读取值班信息...")
|
||||||
duty = pd.read_excel(duty_path, sheet_name= "Sheet1")
|
duty = pd.read_excel(duty_path, sheet_name = "Sheet1")
|
||||||
|
|
||||||
hours_dict = {}
|
hours_dict = {}
|
||||||
index = 0
|
index = 0
|
||||||
|
|
@ -39,9 +43,9 @@ index = 0
|
||||||
time_fmt = "%H:%M"
|
time_fmt = "%H:%M"
|
||||||
|
|
||||||
for members in duty["人员"]:
|
for members in duty["人员"]:
|
||||||
time = duty["时间"][index].split('-')
|
period = duty["时间"][index].split('-')
|
||||||
time_end = datetime.datetime.strptime(time[1], time_fmt)
|
time_end = datetime.datetime.strptime(period[1], time_fmt)
|
||||||
time_start = datetime.datetime.strptime(time[0], time_fmt)
|
time_start = datetime.datetime.strptime(period[0], time_fmt)
|
||||||
hours = (time_end - time_start).seconds / 3600
|
hours = (time_end - time_start).seconds / 3600
|
||||||
|
|
||||||
members = members.split('、')
|
members = members.split('、')
|
||||||
|
|
@ -68,7 +72,7 @@ hour_path = r'./hour.xlsx'
|
||||||
|
|
||||||
id_list = []
|
id_list = []
|
||||||
for member in hours_dict.keys():
|
for member in hours_dict.keys():
|
||||||
id_list.append(id_dict[member])
|
id_list.append(str(id_dict[member]))
|
||||||
|
|
||||||
df = pd.DataFrame({"姓名": hours_dict.keys(), "身份证号码": id_list, "荣誉时数值": hours_dict.values()})
|
df = pd.DataFrame({"姓名": hours_dict.keys(), "身份证号码": id_list, "荣誉时数值": hours_dict.values()})
|
||||||
df = df.set_index("姓名")
|
df = df.set_index("姓名")
|
||||||
|
|
|
||||||
BIN
值班排班表示例.xlsx
BIN
值班排班表示例.xlsx
Binary file not shown.
BIN
身份信息表示例.xlsx
BIN
身份信息表示例.xlsx
Binary file not shown.
Loading…
Reference in New Issue