20231106
This commit is contained in:
1 parent
27b50a7301
commit
e16507c521
1 file changed
+121
-4
+121
-4
@@ -4,12 +4,11 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "1c72f0cf-165b-4025-af9d-6771e4a0a5d1",
|
"id": "1c72f0cf-165b-4025-af9d-6771e4a0a5d1",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"jp-MarkdownHeadingCollapsed": true,
|
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"toc-hr-collapsed": true
|
"toc-hr-collapsed": true
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## 2022年体质检测"
|
"# 2022年体质检测"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -643,7 +642,15 @@
|
|||||||
"id": "c103301b-d540-4bf5-861a-0eb2e313e26e",
|
"id": "c103301b-d540-4bf5-861a-0eb2e313e26e",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"## 2023年体质检测"
|
"# 2023年体质检测"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "1ab2aa22-5cc2-4f53-a28d-b30b1ecab15f",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 人员信息处理"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1086,10 +1093,120 @@
|
|||||||
"wb.save(filename)"
|
"wb.save(filename)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "e613feb8-b03d-4afc-aa56-c91d80903a22",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 生成人员信息"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"id": "0bafbf66-c909-413e-a9c1-c1a5f9c22953",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-06T02:24:15.934701Z",
|
||||||
|
"iopub.status.busy": "2023-11-06T02:24:15.934225Z",
|
||||||
|
"iopub.status.idle": "2023-11-06T02:24:16.060592Z",
|
||||||
|
"shell.execute_reply": "2023-11-06T02:24:16.060193Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-06T02:24:15.934664Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"wb = openpyxl.load_workbook('data/北海炼化人员信息(2023年).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, 2).value\n",
|
||||||
|
" dict1['sex'] = sheet.cell(n, 3).value\n",
|
||||||
|
" dict1['unit'] = sheet.cell(n, 4).value\n",
|
||||||
|
" dict1['birth'] = sheet.cell(n,5).value\n",
|
||||||
|
" dict1['phone'] = sheet.cell(n,6).value\n",
|
||||||
|
" person[code] = dict1\n",
|
||||||
|
"filename = 'data/北海炼化2023年.json'\n",
|
||||||
|
"with open(filename, 'w') as fl:\n",
|
||||||
|
" json.dump(person, fl, ensure_ascii=False)\n",
|
||||||
|
"print('ok')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "b373563f-0b78-4d37-9428-89d3f4e04883",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 生成读卡系统文件"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"id": "ff1e0a37-6119-4f64-8e05-4d25cb144817",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-11-06T02:24:19.656268Z",
|
||||||
|
"iopub.status.busy": "2023-11-06T02:24:19.655917Z",
|
||||||
|
"iopub.status.idle": "2023-11-06T02:24:19.664523Z",
|
||||||
|
"shell.execute_reply": "2023-11-06T02:24:19.664185Z",
|
||||||
|
"shell.execute_reply.started": "2023-11-06T02:24:19.656254Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/北海炼化2023年.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_北海炼化.json\", \"w\",encoding = 'utf-8') as file:\n",
|
||||||
|
" file.write(json_data) \n",
|
||||||
|
"print('ok')"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "0bafbf66-c909-413e-a9c1-c1a5f9c22953",
|
"id": "43af17bf-d80a-4c04-8bb3-25c192c9443f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
|
|||||||
Reference in new issue
Block a user