This commit is contained in:
512song committed 2023-11-14 22:07:38 +08:00
1 parent 2185fd37aa
commit 066a903916
1 file changed
+185 -233
+185 -233
View File
@@ -4,7 +4,6 @@
"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
}, },
@@ -15,7 +14,10 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "61f4a6eb-797e-4fe2-95df-e27b316c95f1", "id": "61f4a6eb-797e-4fe2-95df-e27b316c95f1",
"metadata": {}, "metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [ "source": [
"### 人员基本信息导入" "### 人员基本信息导入"
] ]
@@ -593,16 +595,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 46, "execution_count": null,
"id": "e1b2e465-3ebb-448f-a3df-e2aaab70e688", "id": "e1b2e465-3ebb-448f-a3df-e2aaab70e688",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-02-26T02:09:56.640500Z",
"iopub.status.busy": "2023-02-26T02:09:56.639970Z",
"iopub.status.idle": "2023-02-26T02:10:09.671647Z",
"shell.execute_reply": "2023-02-26T02:10:09.670363Z",
"shell.execute_reply.started": "2023-02-26T02:09:56.640450Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [],
@@ -668,27 +663,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 98, "execution_count": null,
"id": "648d597d-2ac4-470c-9562-271e3e2863d6", "id": "648d597d-2ac4-470c-9562-271e3e2863d6",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T08:13:47.536294Z",
"iopub.status.busy": "2023-10-25T08:13:47.535980Z",
"iopub.status.idle": "2023-10-25T08:13:47.835840Z",
"shell.execute_reply": "2023-10-25T08:13:47.835233Z",
"shell.execute_reply.started": "2023-10-25T08:13:47.536267Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [ "source": [
"import os,sys,shutil\n", "import os,sys,shutil\n",
"import json\n", "import json\n",
@@ -743,30 +723,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 75, "execution_count": null,
"id": "a2c1c315-c522-433a-9611-e08dca2445a9", "id": "a2c1c315-c522-433a-9611-e08dca2445a9",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T07:39:03.122723Z",
"iopub.status.busy": "2023-10-25T07:39:03.122416Z",
"iopub.status.idle": "2023-10-25T07:39:03.163768Z",
"shell.execute_reply": "2023-10-25T07:39:03.163068Z",
"shell.execute_reply.started": "2023-10-25T07:39:03.122696Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"董红军 18877976757\n",
"苗光浩 13927509537\n",
"440906199104060046 440906199104060046\n",
"黄仁进 13807799565\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"\n", "\n",
@@ -797,28 +759,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 48, "execution_count": null,
"id": "7ba235d2-4638-4479-babb-2f9867c177c2", "id": "7ba235d2-4638-4479-babb-2f9867c177c2",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T06:41:49.969813Z",
"iopub.status.busy": "2023-10-25T06:41:49.969303Z",
"iopub.status.idle": "2023-10-25T06:41:49.984085Z",
"shell.execute_reply": "2023-10-25T06:41:49.982976Z",
"shell.execute_reply.started": "2023-10-25T06:41:49.969767Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"440906199104060046 凌倩\n",
"440906199104060046 陈继杨\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"\n", "\n",
@@ -833,32 +779,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 67, "execution_count": null,
"id": "f9d8aafa-9a00-484a-a3c2-b3e9252b505d", "id": "f9d8aafa-9a00-484a-a3c2-b3e9252b505d",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T07:22:33.048929Z",
"iopub.status.busy": "2023-10-25T07:22:33.048318Z",
"iopub.status.idle": "2023-10-25T07:22:33.073020Z",
"shell.execute_reply": "2023-10-25T07:22:33.070785Z",
"shell.execute_reply.started": "2023-10-25T07:22:33.048870Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"18877976757 刘前程\n",
"13927509537 黄洁强\n",
"18877976757 董红军\n",
"13927509537 苗光浩\n",
"13807799565 谢昌俊\n",
"13807799565 黄仁进\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"\n", "\n",
@@ -881,27 +807,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 101, "execution_count": null,
"id": "dff13fe9-d5cd-45e3-a3e7-f47d12560699", "id": "dff13fe9-d5cd-45e3-a3e7-f47d12560699",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T08:13:58.275474Z",
"iopub.status.busy": "2023-10-25T08:13:58.275157Z",
"iopub.status.idle": "2023-10-25T08:13:58.306694Z",
"shell.execute_reply": "2023-10-25T08:13:58.305838Z",
"shell.execute_reply.started": "2023-10-25T08:13:58.275446Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"\n", "\n",
@@ -940,27 +851,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 99, "execution_count": null,
"id": "61f8d7c3-b7f2-44b7-86f1-5b29d22193cb", "id": "61f8d7c3-b7f2-44b7-86f1-5b29d22193cb",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T08:13:51.263500Z",
"iopub.status.busy": "2023-10-25T08:13:51.263208Z",
"iopub.status.idle": "2023-10-25T08:13:51.342292Z",
"shell.execute_reply": "2023-10-25T08:13:51.341571Z",
"shell.execute_reply.started": "2023-10-25T08:13:51.263475Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"import openpyxl\n", "import openpyxl\n",
@@ -996,27 +892,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 100, "execution_count": null,
"id": "8da8e47d-b62b-4719-82d5-fcfc61473e08", "id": "8da8e47d-b62b-4719-82d5-fcfc61473e08",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T08:13:54.195888Z",
"iopub.status.busy": "2023-10-25T08:13:54.195597Z",
"iopub.status.idle": "2023-10-25T08:13:54.261587Z",
"shell.execute_reply": "2023-10-25T08:13:54.260957Z",
"shell.execute_reply.started": "2023-10-25T08:13:54.195864Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"import openpyxl\n", "import openpyxl\n",
@@ -1063,16 +944,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 102, "execution_count": null,
"id": "474786b8-e172-4335-aa4d-bb5bde17ceb7", "id": "474786b8-e172-4335-aa4d-bb5bde17ceb7",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T08:14:01.457995Z",
"iopub.status.busy": "2023-10-25T08:14:01.457489Z",
"iopub.status.idle": "2023-10-25T08:14:01.591382Z",
"shell.execute_reply": "2023-10-25T08:14:01.590589Z",
"shell.execute_reply.started": "2023-10-25T08:14:01.457949Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [],
@@ -1108,27 +982,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 106, "execution_count": null,
"id": "0bafbf66-c909-413e-a9c1-c1a5f9c22953", "id": "0bafbf66-c909-413e-a9c1-c1a5f9c22953",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-11-14T05:55:33.805333Z",
"iopub.status.busy": "2023-11-14T05:55:33.804539Z",
"iopub.status.idle": "2023-11-14T05:55:33.957265Z",
"shell.execute_reply": "2023-11-14T05:55:33.956626Z",
"shell.execute_reply.started": "2023-11-14T05:55:33.805258Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [ "source": [
"import openpyxl\n", "import openpyxl\n",
"import json\n", "import json\n",
@@ -1148,7 +1007,7 @@
" dict1['unit'] = sheet.cell(n, 4).value\n", " dict1['unit'] = sheet.cell(n, 4).value\n",
" dict1['birth'] = sheet.cell(n,5).value\n", " dict1['birth'] = sheet.cell(n,5).value\n",
" if sheet.cell(n,6).value is not None:\n", " if sheet.cell(n,6).value is not None:\n",
" dict1['phone'] = sheet.cell(n,6).value \n", " dict1['phone'] = str(sheet.cell(n,6).value) \n",
" person[code] = dict1\n", " person[code] = dict1\n",
"filename = 'data/北海炼化2023年.json'\n", "filename = 'data/北海炼化2023年.json'\n",
"with open(filename, 'w') as fl:\n", "with open(filename, 'w') as fl:\n",
@@ -1166,27 +1025,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"id": "ff1e0a37-6119-4f64-8e05-4d25cb144817", "id": "ff1e0a37-6119-4f64-8e05-4d25cb144817",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-11-06T02:45:31.688480Z",
"iopub.status.busy": "2023-11-06T02:45:31.688086Z",
"iopub.status.idle": "2023-11-06T02:45:31.699445Z",
"shell.execute_reply": "2023-11-06T02:45:31.699024Z",
"shell.execute_reply.started": "2023-11-06T02:45:31.688449Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"\n", "\n",
@@ -1219,28 +1063,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 107, "execution_count": null,
"id": "1aa45b35-7376-4c50-8275-79b090a6c758", "id": "1aa45b35-7376-4c50-8275-79b090a6c758",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-11-14T06:00:16.626017Z",
"iopub.status.busy": "2023-11-14T06:00:16.625735Z",
"iopub.status.idle": "2023-11-14T06:00:16.685336Z",
"shell.execute_reply": "2023-11-14T06:00:16.684762Z",
"shell.execute_reply.started": "2023-11-14T06:00:16.625993Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"697\n",
"697\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"import time\n", "import time\n",
@@ -1270,17 +1098,26 @@
"#print(list1)\n", "#print(list1)\n",
"for result in list1:\n", "for result in list1:\n",
" user = str(result[2])\n", " user = str(result[2])\n",
" \n",
" if user in dict1.keys(): \n", " if user in dict1.keys(): \n",
" m_item = str(result[3]) \n", " m_item = str(result[3]) \n",
" re_ta.setdefault(user,{}) \n", " re_ta.setdefault(user,{}) \n",
" re_ta[user]['name'] = dict1[user]['name']\n", " re_ta[user]['name'] = dict1[user]['name']\n",
" re_ta[user]['sex'] = dict1[user]['sex'] \n", " re_ta[user]['sex'] = dict1[user]['sex'] \n",
" re_ta[user]['unit'] = dict1[user]['unit']\n", " re_ta[user]['unit'] = dict1[user]['unit']\n",
" re_ta[user]['phone'] = dict1[user]['phone']\n",
" item_name = item[m_item]['name']\n", " item_name = item[m_item]['name']\n",
" re_ta[user].setdefault(item_name,{}) \n", " re_ta[user].setdefault(item_name,{}) \n",
" score = int(result[4])/item[m_item]['divisor'] \n", " score = int(result[4])/item[m_item]['divisor'] \n",
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n", " re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
" re_ta[user]['rq'] = str(result[6]) \n", " re_ta[user]['rq'] = str(result[6]) \n",
" rq = date.fromisoformat(str(result[6]))\n",
" birth = date.fromisoformat(dict1[user]['birth'])\n",
" days = (rq-birth).days \n",
" re_ta[user]['age'] = int(days/365)\n",
" re_ta[user]['month'] = int(days/365*12)\n",
" \n",
" \n",
"print(len(re_ta))\n", "print(len(re_ta))\n",
"filename = 'data/result_北海炼化2023.json'\n", "filename = 'data/result_北海炼化2023.json'\n",
"\n", "\n",
@@ -1299,16 +1136,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": null,
"id": "1172a79c-ec8f-4274-8c43-6ec11d95f8ca", "id": "1172a79c-ec8f-4274-8c43-6ec11d95f8ca",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-11-11T02:59:00.204405Z",
"iopub.status.busy": "2023-11-11T02:59:00.204011Z",
"iopub.status.idle": "2023-11-11T02:59:00.237385Z",
"shell.execute_reply": "2023-11-11T02:59:00.236828Z",
"shell.execute_reply.started": "2023-11-11T02:59:00.204374Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [],
@@ -1353,31 +1183,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 113, "execution_count": null,
"id": "63d5bccf-7351-4a08-863d-b1ca3b263eca", "id": "63d5bccf-7351-4a08-863d-b1ca3b263eca",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-11-14T06:14:23.732763Z",
"iopub.status.busy": "2023-11-14T06:14:23.732454Z",
"iopub.status.idle": "2023-11-14T06:14:23.789472Z",
"shell.execute_reply": "2023-11-14T06:14:23.788550Z",
"shell.execute_reply.started": "2023-11-14T06:14:23.732734Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "outputs": [],
{
"ename": "ValueError",
"evalue": "invalid literal for int() with base 10: 'ender'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[113], line 38\u001b[0m\n\u001b[1;32m 36\u001b[0m list2\u001b[38;5;241m.\u001b[39mappend(\u001b[38;5;241m0\u001b[39m)\n\u001b[1;32m 37\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m k, v \u001b[38;5;129;01min\u001b[39;00m content\u001b[38;5;241m.\u001b[39mitems():\n\u001b[0;32m---> 38\u001b[0m i \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mint\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mk\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 39\u001b[0m list2[i\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m] \u001b[38;5;241m=\u001b[39m v\n\u001b[1;32m 40\u001b[0m dict2[item[\u001b[38;5;241m2\u001b[39m]] \u001b[38;5;241m=\u001b[39m list2\n",
"\u001b[0;31mValueError\u001b[0m: invalid literal for int() with base 10: 'ender'"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"import csv\n", "import csv\n",
@@ -1407,15 +1218,18 @@
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n", " #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" list1.append(line)\n", " list1.append(line)\n",
"dict2 = {}\n", "dict2 = {}\n",
"psy,tcm,spine = []\n",
"m_rq = '2023-11-14'\n", "m_rq = '2023-11-14'\n",
"rq= date.fromisoformat(m_rq.replace('/','-'))\n", "rq= date.fromisoformat(m_rq.replace('/','-'))\n",
"for item in list1:\n", "for item in list1:\n",
" if item[2] in phone: \n", " if item[2] in phone: \n",
" content = json.loads(item[5])\n", " content = json.loads(item[5])\n",
" list2 = []\n", " \n",
" for i in range(0,60):\n",
" list2.append(0)\n",
" for k, v in content.items():\n", " for k, v in content.items():\n",
" if 'psy' in k:\n",
" i = int(k[3:])\n",
" psy[i] = v\n",
" \n",
" i = int(k[1:])\n", " i = int(k[1:])\n",
" list2[i-1] = v\n", " list2[i-1] = v\n",
" dict2[item[2]] = list2\n", " dict2[item[2]] = list2\n",
@@ -1425,13 +1239,13 @@
" if k not in dict1.keys():\n", " if k not in dict1.keys():\n",
" dict1.setdefault(k,{})\n", " dict1.setdefault(k,{})\n",
" dict1[k] = dict3[k]\n", " dict1[k] = dict3[k]\n",
" days = (rq-birth).days \n", " days = (v['rq']-v['birth']).days \n",
" dict1[k]['age'] = int(days/365)\n", " dict1[k]['age'] = int(days/365)\n",
" dict1[k]['month'] = int(days/365*12)\n", " dict1[k]['month'] = int(days/365*12)\n",
" \n", " \n",
" dict1[k]['tcm'] = dict2[str(v['phone'])]\n", " dict1[k]['tcm'] = dict2[str(v['phone'])]\n",
" \n", " \n",
"filename = 'data/result_北海炼化new.json'\n", "filename = 'data/result_北海炼化2023.json'\n",
"\n", "\n",
"with open(filename,'w') as fl:\n", "with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False) " " json.dump(dict1, fl, ensure_ascii=False) "
@@ -1441,6 +1255,144 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "c0128f52-8697-4258-aba0-89a522fb9cc0", "id": "c0128f52-8697-4258-aba0-89a522fb9cc0",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"filename = 'data/result_北海炼化2023.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/北海炼化2023年.json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl)\n",
"\n",
"phone = {}\n",
"\n",
"for k,v in dict3.items():\n",
" if 'phone' in v.keys():\n",
" phone[v['phone']] = k\n",
"list1 = []\n",
"filename = 'data/Survey_20231114.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
" for line in fl:\n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" list1.append(line)\n",
"#print(list1)\n",
"dict2 = {}\n",
"#psy = []\n",
"#m_rq = '2023-11-14'\n",
"#rq= date.fromisoformat(m_rq.replace('/','-'))\n",
"for item in list1:\n",
" if item[2] in phone.keys(): \n",
" content = json.loads(item[5])\n",
" print(phone[item[2]])\n",
" if phone[item[2]] not in dict1.keys():\n",
" dict1[phone[item[2]]] = dict3[phone[item[2]]]\n",
" rq = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
" #dict1[phone[item[2]]]['rq'] = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
" \n",
" psy = []\n",
" tcm = []\n",
" spine = []\n",
" for k, v in content.items():\n",
" if 'psy' in k:\n",
" i = int(k[3:])\n",
" psy.append(v)\n",
" if 'tcm' in k:\n",
" i = int(k[3:])\n",
" tcm.append(v)\n",
" if 'spine' in k:\n",
" i = int(k[5:])\n",
" spine.append(v)\n",
" if len(psy) > 1:\n",
" dict1[phone[item[2]]]['psy'] = psy\n",
" if len(tcm) > 1:\n",
" dict1[phone[item[2]]]['tcm'] = tcm\n",
" if len(psy) > 1:\n",
" dict1[phone[item[2]]]['spine'] = spine\n",
" birth = date.fromisoformat(dict3[phone[item[2]]]['birth'].replace('/','-'))\n",
" \n",
" days = (rq-birth).days \n",
" dict1[phone[item[2]]]['age'] = int(days/365)\n",
" dict1[phone[item[2]]]['month'] = int(days/365*12)\n",
"filename = 'data/result_北海炼化2023.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False) "
]
},
{
"cell_type": "markdown",
"id": "0690df67-fc6b-4386-a18f-a99bd065c894",
"metadata": {},
"source": [
"## 统计项目数"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "87e0c0f1-5f07-424d-98b2-aa301fd77c82",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"\n",
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"\n",
"filename = 'data/result_北海炼化2023.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"list1 = []\n",
"for k,v in dict1.items():\n",
" i = 0\n",
" list2 = []\n",
" for item in items:\n",
" if item in v.keys():\n",
" i+=1\n",
" print(k)\n",
" list2 = [k,v['name'],v['sex'],v['age'],v['unit'],v['phone'],i]\n",
" if 'psy' in v.keys():\n",
" list2.append(1)\n",
" else:\n",
" list2.append(0)\n",
" if 'tcm' in v.keys():\n",
" list2.append(1)\n",
" else:\n",
" list2.append(0)\n",
" if 'spine' in v.keys():\n",
" list2.append(1)\n",
" else:\n",
" list2.append(0)\n",
" list1.append(list2)\n",
"filename = 'data/北海炼化员工测试项目情况表.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"\n",
"for row in list1:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename) "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7fdcbcc9-361b-4304-98b5-e16639801742",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []