This commit is contained in:
512song committed 2025-05-30 18:21:50 +08:00
1 parent a08571544f
commit c2b6f9b675
4 files changed
+234 -178

No files matched your search

+118 -1
View File
@@ -1277,10 +1277,127 @@
"print('ok') "
]
},
{
"cell_type": "markdown",
"id": "4c2bb4c7-a884-4ade-a6a5-b080dc0a3d7a",
"metadata": {},
"source": [
"# 2025年体质检测"
]
},
{
"cell_type": "markdown",
"id": "553ccd00-fcaa-40af-a7fc-fbd157196023",
"metadata": {},
"source": [
"## 体测人员导入"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "3e6da1e5-4b4e-448a-9663-815372da636b",
"metadata": {
"execution": {
"iopub.execute_input": "2025-05-30T06:30:09.042788Z",
"iopub.status.busy": "2025-05-30T06:30:09.041974Z",
"iopub.status.idle": "2025-05-30T06:30:09.102061Z",
"shell.execute_reply": "2025-05-30T06:30:09.101519Z",
"shell.execute_reply.started": "2025-05-30T06:30:09.042708Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\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 = int(sheet.cell(n, 1).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 3).value\n",
" dict1['sex'] = sheet.cell(n, 4).value\n",
" dict1['unit'] = sheet.cell(n, 6).value\n",
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0] \n",
" dict1['phone'] = sheet.cell(n,7).value\n",
" dict1['id'] = str(sheet.cell(n,2).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('ok')"
]
},
{
"cell_type": "markdown",
"id": "bdd3dec8-e443-4365-a03a-7db2e698061e",
"metadata": {},
"source": [
"## 生成读卡系统文件"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "93610ae6-098d-434a-a19a-6071aaa65500",
"metadata": {
"execution": {
"iopub.execute_input": "2025-05-30T06:32:05.818838Z",
"iopub.status.busy": "2025-05-30T06:32:05.818215Z",
"iopub.status.idle": "2025-05-30T06:32:05.831425Z",
"shell.execute_reply": "2025-05-30T06:32:05.830336Z",
"shell.execute_reply.started": "2025-05-30T06:32:05.818778Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"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/data_东营石油工程设计院2025.json\", \"w\",encoding = 'utf-8') as file:\n",
" file.write(json_data) \n",
"print('ok')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b089745c-504b-4593-a6be-5d1da1321c95",
"id": "d7bcbeb2-2e6e-40a4-b1ef-35b95462dc44",
"metadata": {},
"outputs": [],
"source": []