This commit is contained in:
512song committed 2025-11-10 20:06:46 +08:00
1 parent 03de3b1663
commit f3a7c981d5
4 files changed
+408 -184

No files matched your search

+119 -1
View File
@@ -2793,7 +2793,9 @@
{
"cell_type": "markdown",
"id": "08bcbf58-4356-4f30-850f-0d0ff0e2528b",
"metadata": {},
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"# 第三次体测(2024年10月)"
]
@@ -3395,6 +3397,122 @@
"print('ok') "
]
},
{
"cell_type": "markdown",
"id": "dd32c384-262d-4137-bb44-2d3a590438f4",
"metadata": {},
"source": [
"# 2025年体测"
]
},
{
"cell_type": "markdown",
"id": "cd516502-5515-47f5-85a0-2312d78cdca7",
"metadata": {},
"source": [
"## 体测人员导入"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "c101eccb-a2f3-4404-9583-682cec049160",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-10T10:34:09.617871Z",
"iopub.status.busy": "2025-11-10T10:34:09.617343Z",
"iopub.status.idle": "2025-11-10T10:34:10.297071Z",
"shell.execute_reply": "2025-11-10T10:34:10.296491Z",
"shell.execute_reply.started": "2025-11-10T10:34:09.617822Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5053 ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"from datetime import date\n",
"\n",
"wb = openpyxl.load_workbook('data/天津石化人员2025.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"\n",
"for n in range(2, sheet.max_row+1):\n",
" code = str(sheet.cell(n, 1).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 4).value\n",
" dict1['sex'] = sheet.cell(n, 5).value\n",
" dict1['birth'] = str(sheet.cell(n, 6).value).replace('/','-').split(' ')[0] \n",
" dict1['unit'] = sheet.cell(n, 2).value\n",
" dict1['sub_unit'] = sheet.cell(n, 3).value\n",
" person[code] = dict1\n",
"filename = 'data/天津石化人员2025.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print(len(person),'ok')"
]
},
{
"cell_type": "markdown",
"id": "3319058d-0a39-46f7-b493-260e1b529786",
"metadata": {},
"source": [
"## 生成读卡系统文件"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "85bae94e-f480-4c0b-a120-e516e6a5c14d",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-10T10:34:12.756830Z",
"iopub.status.busy": "2025-11-10T10:34:12.756579Z",
"iopub.status.idle": "2025-11-10T10:34:12.798482Z",
"shell.execute_reply": "2025-11-10T10:34:12.797837Z",
"shell.execute_reply.started": "2025-11-10T10:34:12.756807Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5053 ok\n"
]
}
],
"source": [
"import json\n",
"\n",
"filename = 'data/天津石化人员2025.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"for k, v in dict1.items():\n",
" dict2 = {}\n",
" #if dict1['sex'] =='男':\n",
" # sex = 1\n",
" \n",
" dict2 = {'id':k,'name':v['name'],'gender':v['sex'],'birth':v['birth'],'unit':v['unit']+'-'+v['sub_unit']}\n",
" list1.append(dict2)\n",
"json_data = json.dumps(list1,ensure_ascii=False, indent=4) \n",
"\n",
"# 将 json 数据写入文件\n",
"with open(\"data/card_天津石化2025.json\", \"w\",encoding = 'utf-8') as file:\n",
" file.write(json_data) \n",
"print(len(list1),'ok')"
]
},
{
"cell_type": "markdown",
"id": "85a03b00-9624-4ae9-aa6d-386798d457df",