This commit is contained in:
512song committed 2025-11-03 17:24:57 +08:00
1 parent 9ec7907bde
commit 45b176e01e
2 files changed
+250 -162

No files matched your search

+122 -2
View File
@@ -4,6 +4,7 @@
"cell_type": "markdown",
"id": "1c72f0cf-165b-4025-af9d-6771e4a0a5d1",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
@@ -2180,7 +2181,9 @@
{
"cell_type": "markdown",
"id": "76c5c17a-462d-4a7b-95a5-6b895f5a25dc",
"metadata": {},
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"# 2024年体质检测"
]
@@ -3085,10 +3088,127 @@
"print('ok') "
]
},
{
"cell_type": "markdown",
"id": "75ee44f4-2874-44eb-b071-7666f52a60f1",
"metadata": {},
"source": [
"# 2025年体质检测"
]
},
{
"cell_type": "markdown",
"id": "78f7f826-1f38-4c8d-8483-ddde43dce321",
"metadata": {},
"source": [
"## 体测人员导入"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "58f6dbab-9ea2-4295-ae78-36951b67c2d3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-31T04:59:33.610242Z",
"iopub.status.busy": "2025-10-31T04:59:33.609508Z",
"iopub.status.idle": "2025-10-31T04:59:33.725719Z",
"shell.execute_reply": "2025-10-31T04:59:33.725272Z",
"shell.execute_reply.started": "2025-10-31T04:59:33.610173Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"854 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 = sheet.cell(n, 1).value\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 2).value\n",
" dict1['sex'] = sheet.cell(n, 3).value\n",
" dict1['birth'] = str(sheet.cell(n, 7).value).replace('/','-').split(' ')[0] \n",
" dict1['unit'] = sheet.cell(n, 6).value\n",
" dict1['phone'] = str(sheet.cell(n, 5).value)\n",
" dict1['id'] = sheet.cell(n, 4).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": "ae6b80a0-fe84-42eb-9fb6-c7844b0aa268",
"metadata": {},
"source": [
"## 生成读卡系统文件"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "dbe52ce7-f801-44c6-b675-f0a84867c4d9",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-31T04:59:36.768146Z",
"iopub.status.busy": "2025-10-31T04:59:36.767582Z",
"iopub.status.idle": "2025-10-31T04:59:36.787010Z",
"shell.execute_reply": "2025-10-31T04:59:36.786336Z",
"shell.execute_reply.started": "2025-10-31T04:59:36.768082Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"854 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']}\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": "code",
"execution_count": null,
"id": "712572b1-7a9b-4022-93de-13166508a307",
"id": "8ac3a30f-002f-49b4-bbb0-c63ac37037f9",
"metadata": {},
"outputs": [],
"source": []