20211110
This commit is contained in:
1 parent
a707437a2b
commit
5cfd8f1190
1 file changed
+671
-22
+671
-22
@@ -793,6 +793,655 @@
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3711130b-59e3-4844-ac31-234ba77cd46c",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"## 脊柱症状统计"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ae25fffb-4682-49b1-90aa-218504ac88d7",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 脊椎症状自评代码矩阵生成"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"id": "5e49d9c5-69cc-42dc-b872-738b6985f7a3",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2021-11-09T23:57:38.404084Z",
|
||||
"iopub.status.busy": "2021-11-09T23:57:38.402865Z",
|
||||
"iopub.status.idle": "2021-11-09T23:57:38.458541Z",
|
||||
"shell.execute_reply": "2021-11-09T23:57:38.456244Z",
|
||||
"shell.execute_reply.started": "2021-11-09T23:57:38.403976Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/脊椎症状自评矩阵代码表.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"dict1 = {}\n",
|
||||
"\n",
|
||||
"for n in range(2,sheet.max_row+1):\n",
|
||||
" mxh = sheet.cell(n,1).value\n",
|
||||
" dict1.setdefault(mxh,{})\n",
|
||||
" mwt = sheet.cell(n,2).value\n",
|
||||
" mtj = sheet.cell(n,3).value\n",
|
||||
" mdm = sheet.cell(n,4).value\n",
|
||||
" dict1[mxh]['代码'] = mdm\n",
|
||||
" dict1[mxh]['问题'] = mwt\n",
|
||||
" dict1[mxh]['条件'] = mtj\n",
|
||||
" \n",
|
||||
"filename = 'data/脊柱症状自评代码矩阵.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict1, fl,ensure_ascii=False) \n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7520a013-d31b-46fc-af9d-91740d24b0f0",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2021-11-09T23:24:59.628916Z",
|
||||
"iopub.status.busy": "2021-11-09T23:24:59.627689Z",
|
||||
"iopub.status.idle": "2021-11-09T23:24:59.638848Z",
|
||||
"shell.execute_reply": "2021-11-09T23:24:59.636589Z",
|
||||
"shell.execute_reply.started": "2021-11-09T23:24:59.628807Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"### 脊椎症状自评数据矩阵生成"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"id": "61f92c63-d359-4c4b-ad64-9b8268a3e992",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2021-11-09T23:55:58.689535Z",
|
||||
"iopub.status.busy": "2021-11-09T23:55:58.688298Z",
|
||||
"iopub.status.idle": "2021-11-09T23:55:58.726710Z",
|
||||
"shell.execute_reply": "2021-11-09T23:55:58.724689Z",
|
||||
"shell.execute_reply.started": "2021-11-09T23:55:58.689426Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n",
|
||||
"543\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"dict1 = {}\n",
|
||||
"dict1['颈椎'] = 1000\n",
|
||||
"dict1['胸椎'] = 100\n",
|
||||
"dict1['腰椎'] = 10\n",
|
||||
"dict1['骶尾椎'] = 1\n",
|
||||
"dict_all = {}\n",
|
||||
"\n",
|
||||
"filename = '脊柱症状自我诊断表统计.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl) \n",
|
||||
"\n",
|
||||
"list_all = dict2.keys()\n",
|
||||
"filename = '脊柱症状统计汇总表.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl) \n",
|
||||
"list_zz = dict2.keys()\n",
|
||||
"sorted(list_all)\n",
|
||||
"for item in list_all:\n",
|
||||
" if item not in list_zz:\n",
|
||||
" dict_all[item] = '0000'\n",
|
||||
" else:\n",
|
||||
" m_sum = 0\n",
|
||||
" for item1 in dict2[item]:\n",
|
||||
" m_sum += dict1[item1]\n",
|
||||
" dict_all[item] = str(m_sum).rjust(4,'0')\n",
|
||||
"filename = 'data/脊柱症状自评数据矩阵.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict_all, fl,ensure_ascii=False) \n",
|
||||
"print('ok') \n",
|
||||
"print(len(dict_all))\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "bdc4673c-a0e2-4c8c-913a-47e39c7a366e",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 脊椎症状自评数据统计(人数)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 45,
|
||||
"id": "908302d5-252d-403e-80e5-fdc0694061b8",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2021-11-10T00:40:33.719985Z",
|
||||
"iopub.status.busy": "2021-11-10T00:40:33.718720Z",
|
||||
"iopub.status.idle": "2021-11-10T00:40:34.399895Z",
|
||||
"shell.execute_reply": "2021-11-10T00:40:34.385355Z",
|
||||
"shell.execute_reply.started": "2021-11-10T00:40:33.719864Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{'0000': '0个症状', '1000': '仅有颈椎问题', '0100': '仅有胸椎问题', '0010': '仅有腰椎问题', '0001': '仅有骶尾椎问题', '1100': '颈椎问题+胸椎问题', '1010': '颈椎问题+腰椎问题', '1001': '颈椎问题+骶尾椎问题', '0110': '胸椎问题+腰椎问题', '0101': '胸椎问题+骶尾椎问题', '0011': '腰椎问题+骶尾椎问题', '1110': '颈椎问题+胸椎问题+腰椎问题', '1101': '颈椎问题+胸椎问题+骶尾椎问题', '0111': '胸椎问题+腰椎问题+骶尾椎问题', '1011': '颈椎问题+腰椎问题+骶尾椎问题', '1111': '颈椎问题+胸椎问题+腰椎问题+骶尾椎问题'}\n",
|
||||
"[('0000', 103), ('1110', 93), ('1000', 92), ('1010', 60), ('1111', 51), ('1100', 42), ('0010', 24), ('0110', 17), ('0100', 15), ('1011', 12), ('1001', 9), ('1101', 8), ('0011', 6), ('0001', 6), ('0101', 3), ('0111', 2)]\n",
|
||||
"{'一线部门': {'1111': 40, '0110': 15, '1110': 79, '1010': 47, '1100': 34, '0000': 84, '0010': 17, '1011': 7, '1000': 76, '0001': 4, '1101': 7, '0100': 13, '1001': 7, '0011': 5, '0101': 3}, '管理部门': {'1000': 16, '1110': 14, '1011': 5, '0001': 2, '1111': 11, '1100': 8, '0110': 2, '0000': 19, '0010': 7, '1010': 13, '0011': 1, '1001': 2, '1101': 1, '0111': 2, '0100': 2}}\n",
|
||||
"一线部门\n",
|
||||
"0个症状 84\n",
|
||||
"仅有颈椎问题 76\n",
|
||||
"仅有胸椎问题 13\n",
|
||||
"仅有腰椎问题 17\n",
|
||||
"仅有骶尾椎问题 4\n",
|
||||
"颈椎问题+胸椎问题 34\n",
|
||||
"颈椎问题+腰椎问题 47\n",
|
||||
"颈椎问题+骶尾椎问题 7\n",
|
||||
"胸椎问题+腰椎问题 15\n",
|
||||
"胸椎问题+骶尾椎问题 3\n",
|
||||
"腰椎问题+骶尾椎问题 5\n",
|
||||
"颈椎问题+胸椎问题+腰椎问题 79\n",
|
||||
"颈椎问题+胸椎问题+骶尾椎问题 7\n",
|
||||
"颈椎问题+腰椎问题+骶尾椎问题 7\n",
|
||||
"颈椎问题+胸椎问题+腰椎问题+骶尾椎问题 40\n",
|
||||
"管理部门\n",
|
||||
"0个症状 19\n",
|
||||
"仅有颈椎问题 16\n",
|
||||
"仅有胸椎问题 2\n",
|
||||
"仅有腰椎问题 7\n",
|
||||
"仅有骶尾椎问题 2\n",
|
||||
"颈椎问题+胸椎问题 8\n",
|
||||
"颈椎问题+腰椎问题 13\n",
|
||||
"颈椎问题+骶尾椎问题 2\n",
|
||||
"胸椎问题+腰椎问题 2\n",
|
||||
"腰椎问题+骶尾椎问题 1\n",
|
||||
"颈椎问题+胸椎问题+腰椎问题 14\n",
|
||||
"颈椎问题+胸椎问题+骶尾椎问题 1\n",
|
||||
"胸椎问题+腰椎问题+骶尾椎问题 2\n",
|
||||
"颈椎问题+腰椎问题+骶尾椎问题 5\n",
|
||||
"颈椎问题+胸椎问题+腰椎问题+骶尾椎问题 11\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"fi_xls = 'data/北海炼化名单表(前后台).xlsx'\n",
|
||||
"wb = openpyxl.load_workbook(fi_xls)\n",
|
||||
"sheet = wb.active\n",
|
||||
"depart = {}\n",
|
||||
"for n in range(2,sheet.max_row+1): \n",
|
||||
" m_dm = str(sheet.cell(n,1).value)\n",
|
||||
" m_depart = sheet.cell(n,6).value\n",
|
||||
" depart[m_dm] = m_depart\n",
|
||||
" \n",
|
||||
"filename = 'data/脊柱症状自评代码矩阵.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"dict2 = dict1.values()\n",
|
||||
"dm = {}\n",
|
||||
"for item in dict2:\n",
|
||||
" dm[item['代码']] = item['问题']\n",
|
||||
"print(dm)\n",
|
||||
"list_dm = dm.keys()\n",
|
||||
"filename = 'data/脊柱症状自评数据矩阵.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" data = json.load(fl)\n",
|
||||
"dict_tj = {}\n",
|
||||
"for k, v in data.items():\n",
|
||||
" dict_tj.setdefault(v,0)\n",
|
||||
" dict_tj[v] +=1\n",
|
||||
"\n",
|
||||
"print(new_dict) \n",
|
||||
"result = {}\n",
|
||||
"for k, v in data.items():\n",
|
||||
" result.setdefault(depart[k],{})\n",
|
||||
" result[depart[k]].setdefault(v,0)\n",
|
||||
" result[depart[k]][v] += 1\n",
|
||||
"#new_dict = sorted(result.items(), key = lambda kv:(kv[1], kv[0]),reverse=True) \n",
|
||||
"#print(part)\n",
|
||||
"print(result)\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"m_totle = 0\n",
|
||||
"sheet = wb.active\n",
|
||||
"i = 1\n",
|
||||
"for k, v in result.items():\n",
|
||||
" print(k)\n",
|
||||
" dict3 = {}\n",
|
||||
" for k1, v1 in v.items():\n",
|
||||
" dict3[k1] = v1\n",
|
||||
" for m_dm in dm:\n",
|
||||
" if m_dm in dict3.keys():\n",
|
||||
" print(dm[m_dm],dict3[m_dm])\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3aa7243c-1d20-4a0c-b6b1-bce6ca110222",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 导入基础数据"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "c30ad0bb-1119-4ab4-8c3c-254a4b246d28",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"## 导入脊椎症状对照表\n",
|
||||
"wb = openpyxl.load_workbook('file/脊椎症状对应表.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"dict1 = {}\n",
|
||||
"'''for n in range(2,sheet.max_row+1):\n",
|
||||
" mjz = sheet.cell(n,1).value\n",
|
||||
" dict1.setdefault(mjz,[])\n",
|
||||
" dict1[mjz].append(sheet.cell(n,2).value)\n",
|
||||
"#print(dict1)'''\n",
|
||||
"for n in range(2,sheet.max_row+1):\n",
|
||||
" mzz = sheet.cell(n,2).value\n",
|
||||
" mjz = sheet.cell(n,1).value\n",
|
||||
" dict1[mzz] = mjz\n",
|
||||
"#print(dict1)\n",
|
||||
"filename = '脊柱症状自我诊断表统计.json'\n",
|
||||
"result = {}\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl) \n",
|
||||
"#print(dict1)\n",
|
||||
"for k, v in dict2.items():\n",
|
||||
" result.setdefault(k,[])\n",
|
||||
" for k1, v1 in v.items(): \n",
|
||||
" for zz in v1:\n",
|
||||
" if zz in dict1.keys() and dict1[zz] not in result[k]:\n",
|
||||
" result[k].append(dict1[zz])\n",
|
||||
"\n",
|
||||
"for k in list(result.keys()):\n",
|
||||
" if not result.get(k):\n",
|
||||
" del result[k]\n",
|
||||
"#print(result)\n",
|
||||
"filename = '脊柱症状统计汇总表.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(result, fl,ensure_ascii=False) \n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "10fe9b36-5853-45ce-b291-f6259109fac0",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 统计人数(脊椎)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "e05247bb-1b03-486a-9c59-52882964231e",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"import os,sys,shutil\n",
|
||||
"\n",
|
||||
"## 导入脊椎症状对照表\n",
|
||||
"wb = openpyxl.load_workbook('file/脊椎症状对应表.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"dict1 = {}\n",
|
||||
"for n in range(2,sheet.max_row+1):\n",
|
||||
" mzz = sheet.cell(n,2).value\n",
|
||||
" mjz = sheet.cell(n,1).value\n",
|
||||
" dict1[mzz] = mjz\n",
|
||||
"fi_xls = os.getcwd() + '/北海炼化名单表(202110).xlsx'\n",
|
||||
"wb = openpyxl.load_workbook(fi_xls)\n",
|
||||
"sheet = wb.active\n",
|
||||
"depart = {}\n",
|
||||
"part = []\n",
|
||||
"for n in range(2,sheet.max_row+1): \n",
|
||||
" m_dm = str(sheet.cell(n,1).value)\n",
|
||||
" m_depart = sheet.cell(n,5).value\n",
|
||||
" depart[m_dm] = m_depart\n",
|
||||
" if m_depart not in part:\n",
|
||||
" part.append(m_depart)\n",
|
||||
"filename = '脊柱症状统计汇总表.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl) \n",
|
||||
"result = {}\n",
|
||||
"#print(dict2)\n",
|
||||
"for k, v in dict2.items():\n",
|
||||
" result.setdefault(depart[k],{})\n",
|
||||
" for v1 in v:\n",
|
||||
" result[depart[k]].setdefault(v1,0)\n",
|
||||
" result[depart[k]][v1] += 1\n",
|
||||
"#print(part)\n",
|
||||
"print(result)\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"m_totle = 0\n",
|
||||
"sheet = wb.active\n",
|
||||
"i = 1\n",
|
||||
"for name in part:\n",
|
||||
" m_sum = 0\n",
|
||||
" sheet[f'A{i}'] = name\n",
|
||||
" i +=1\n",
|
||||
" sheet[f'A{i}'] = '脊椎'\n",
|
||||
" sheet[f'B{i}'] = '人数'\n",
|
||||
" i +=1\n",
|
||||
" new_dict = sorted(result[name].items(), key = lambda kv:(kv[1], kv[0]),reverse=True)\n",
|
||||
" for k, v in new_dict:\n",
|
||||
" sheet[f'A{i}'] = k\n",
|
||||
" sheet[f'B{i}'] = v\n",
|
||||
" i +=1\n",
|
||||
" m_sum +=v\n",
|
||||
" sheet[f'A{i}'] = '合计'\n",
|
||||
" sheet[f'B{i}'] = m_sum\n",
|
||||
" m_totle = m_totle + m_sum\n",
|
||||
" i +=2\n",
|
||||
"sheet[f'A{i}'] = '总计'\n",
|
||||
"sheet[f'B{i}'] = m_totle\n",
|
||||
"wb.save('test4.xlsx')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b5e86c3b-d81a-418c-85b5-28f6fd524ba4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 统计全员人数(脊椎)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "761715db-8d24-44e5-9c0e-11df553aa414",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"import os,sys,shutil\n",
|
||||
"\n",
|
||||
"## 导入脊椎症状对照表\n",
|
||||
"wb = openpyxl.load_workbook('file/脊椎症状对应表.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"dict1 = {}\n",
|
||||
"\n",
|
||||
"filename = '脊柱症状统计汇总表.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl) \n",
|
||||
"result = {}\n",
|
||||
"#print(dict2)\n",
|
||||
"for k, v in dict2.items(): \n",
|
||||
" for v1 in v:\n",
|
||||
" result.setdefault(v1,0)\n",
|
||||
" result[v1] += 1\n",
|
||||
"#print(part)\n",
|
||||
"print(result)\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"m_sum = 0\n",
|
||||
"sheet = wb.active\n",
|
||||
"i = 1\n",
|
||||
"sheet[f'A{i}'] = name\n",
|
||||
"i +=1\n",
|
||||
"sheet[f'A{i}'] = '脊椎'\n",
|
||||
"sheet[f'B{i}'] = '人数'\n",
|
||||
"i +=1\n",
|
||||
"new_dict = sorted(result.items(), key = lambda kv:(kv[1], kv[0]),reverse=True)\n",
|
||||
"for k, v in new_dict:\n",
|
||||
" sheet[f'A{i}'] = k\n",
|
||||
" sheet[f'B{i}'] = v\n",
|
||||
" i +=1\n",
|
||||
" m_sum +=v\n",
|
||||
"sheet[f'A{i}'] = '合计'\n",
|
||||
"sheet[f'B{i}'] = m_sum\n",
|
||||
"\n",
|
||||
"wb.save('test4.xlsx')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "832cb4de-cae2-459f-bd16-1c59247614a3",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 统计人数(症状)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "50004904-b326-4e25-819f-81748302d1fe",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"import os,sys,shutil\n",
|
||||
"\n",
|
||||
"## 导入脊椎症状对照表\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('file/脊椎症状对应表.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"dict1 = {}\n",
|
||||
"for n in range(2,sheet.max_row+1):\n",
|
||||
" mzz = sheet.cell(n,2).value\n",
|
||||
" mjz = sheet.cell(n,1).value\n",
|
||||
" dict1[mzz] = mjz\n",
|
||||
"fi_xls = os.getcwd() + '/北海炼化名单表(202110).xlsx'\n",
|
||||
"wb = openpyxl.load_workbook(fi_xls)\n",
|
||||
"sheet = wb.active\n",
|
||||
"depart = {}\n",
|
||||
"part = []\n",
|
||||
"for n in range(2,sheet.max_row+1): \n",
|
||||
" m_dm = str(sheet.cell(n,1).value)\n",
|
||||
" m_depart = sheet.cell(n,5).value\n",
|
||||
" depart[m_dm] = m_depart\n",
|
||||
" if m_depart not in part:\n",
|
||||
" part.append(m_depart)\n",
|
||||
"filename = '脊柱症状自我诊断表统计.json'\n",
|
||||
"result = {}\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl) \n",
|
||||
"#print(dict1)\n",
|
||||
"for k, v in dict2.items():\n",
|
||||
" result.setdefault(k,[])\n",
|
||||
" for k1, v1 in v.items(): \n",
|
||||
" for zz in v1:\n",
|
||||
" if zz in dict1.keys():\n",
|
||||
" result[k].append(zz)\n",
|
||||
"for k in list(result.keys()):\n",
|
||||
" if not result.get(k):\n",
|
||||
" del result[k]\n",
|
||||
"#print(result)\n",
|
||||
"result1 = {}\n",
|
||||
"#print(dict2)\n",
|
||||
"for k, v in result.items():\n",
|
||||
" result1.setdefault(depart[k],{})\n",
|
||||
" for v1 in v:\n",
|
||||
" result1[depart[k]].setdefault(v1,0)\n",
|
||||
" result1[depart[k]][v1] += 1\n",
|
||||
"#print(result1)\n",
|
||||
"\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"i = 1\n",
|
||||
"m_totle = 0\n",
|
||||
"for name in part:\n",
|
||||
" sheet[f'A{i}'] = name\n",
|
||||
" i +=1\n",
|
||||
" sheet[f'A{i}'] = '症状'\n",
|
||||
" sheet[f'B{i}'] = '人数'\n",
|
||||
" i +=1\n",
|
||||
" m_sum = 0\n",
|
||||
" new_dict = sorted(result1[name].items(), key = lambda kv:(kv[1], kv[0]),reverse=True)\n",
|
||||
" for k, v in new_dict:\n",
|
||||
" sheet[f'A{i}'] = k\n",
|
||||
" sheet[f'B{i}'] = v\n",
|
||||
" m_sum +=v\n",
|
||||
" i +=1\n",
|
||||
" sheet[f'A{i}'] = '合计'\n",
|
||||
" sheet[f'B{i}'] = m_sum\n",
|
||||
" m_totle = m_totle + m_sum\n",
|
||||
" i +=2\n",
|
||||
"sheet[f'A{i}'] = '总计'\n",
|
||||
"sheet[f'B{i}'] = m_totle\n",
|
||||
"wb.save('test3.xlsx')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "99fef05f-4141-4fa0-bbaf-bd39acafd68e",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 全员统计(症状)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "31c80cb0-8a8c-408c-a888-cdcbd9963394",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"import os,sys,shutil\n",
|
||||
"\n",
|
||||
"## 导入脊椎症状对照表\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = '脊柱症状自我诊断表统计.json'\n",
|
||||
"result = {}\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl) \n",
|
||||
"#print(dict1)\n",
|
||||
"for k, v in dict2.items():\n",
|
||||
" result.setdefault(k,[])\n",
|
||||
" for k1, v1 in v.items(): \n",
|
||||
" for zz in v1:\n",
|
||||
" if zz in dict1.keys():\n",
|
||||
" result[k].append(zz)\n",
|
||||
"for k in list(result.keys()):\n",
|
||||
" if not result.get(k):\n",
|
||||
" del result[k]\n",
|
||||
"\n",
|
||||
"result1 = {}\n",
|
||||
"#print(dict2)\n",
|
||||
"for k, v in result.items():\n",
|
||||
" \n",
|
||||
" for v1 in v:\n",
|
||||
" result1.setdefault(v1,0)\n",
|
||||
" result1[v1] += 1\n",
|
||||
"#print(result1)\n",
|
||||
"\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"i = 1\n",
|
||||
"m_totle = 0\n",
|
||||
"sheet[f'A{i}'] = name\n",
|
||||
"i +=1\n",
|
||||
"sheet[f'A{i}'] = '症状'\n",
|
||||
"sheet[f'B{i}'] = '人数'\n",
|
||||
"i +=1\n",
|
||||
"m_sum = 0\n",
|
||||
"new_dict = sorted(result1.items(), key = lambda kv:(kv[1], kv[0]),reverse=True)\n",
|
||||
"for k, v in new_dict:\n",
|
||||
" sheet[f'A{i}'] = k\n",
|
||||
" sheet[f'B{i}'] = v\n",
|
||||
" m_sum +=v\n",
|
||||
" i +=1\n",
|
||||
"sheet[f'A{i}'] = '合计'\n",
|
||||
"sheet[f'B{i}'] = m_sum\n",
|
||||
"\n",
|
||||
"wb.save('test3.xlsx')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "90083246-0378-4816-ace1-8a8a9151c3fc",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"## 导入脊椎症状对照表\n",
|
||||
"wb = openpyxl.load_workbook('file/脊椎症状对应表.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"dict1 = {}\n",
|
||||
"'''for n in range(2,sheet.max_row+1):\n",
|
||||
" mjz = sheet.cell(n,1).value\n",
|
||||
" dict1.setdefault(mjz,[])\n",
|
||||
" dict1[mjz].append(sheet.cell(n,2).value)\n",
|
||||
"#print(dict1)'''\n",
|
||||
"for n in range(2,sheet.max_row+1):\n",
|
||||
" mzz = sheet.cell(n,2).value\n",
|
||||
" mjz = sheet.cell(n,1).value\n",
|
||||
" dict1[mzz] = mjz\n",
|
||||
"#print(dict1)\n",
|
||||
"filename = '脊柱症状自我诊断表统计.json'\n",
|
||||
"result = {}\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl) \n",
|
||||
"#print(dict1)\n",
|
||||
"for k, v in dict2.items():\n",
|
||||
" result.setdefault(k,[])\n",
|
||||
" for k1, v1 in v.items():\n",
|
||||
" for zz in v1:\n",
|
||||
" print(zz)\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f9e61ba9-38f8-4b61-bf1e-4e7bbde4f32c",
|
||||
@@ -877,15 +1526,30 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 92,
|
||||
"id": "499a41ef-1b1f-4973-b733-8c322ac1ce09",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2021-11-09T15:22:44.612641Z",
|
||||
"iopub.status.busy": "2021-11-09T15:22:44.611409Z",
|
||||
"iopub.status.idle": "2021-11-09T15:22:44.631806Z",
|
||||
"shell.execute_reply": "2021-11-09T15:22:44.628880Z",
|
||||
"shell.execute_reply.started": "2021-11-09T15:22:44.612531Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"440\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"filename = '北海炼化公司职工心理健康量表统计.json'\n",
|
||||
"filename = '脊柱症状统计汇总表.json'\n",
|
||||
"item = {}\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
@@ -903,16 +1567,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": null,
|
||||
"id": "d1b557c1-e34c-4b15-8a5b-fcd5e4b62a64",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2021-11-08T12:32:32.248333Z",
|
||||
"iopub.status.busy": "2021-11-08T12:32:32.246928Z",
|
||||
"iopub.status.idle": "2021-11-08T12:33:45.304866Z",
|
||||
"shell.execute_reply": "2021-11-08T12:33:45.302666Z",
|
||||
"shell.execute_reply.started": "2021-11-08T12:32:32.248068Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
@@ -958,22 +1615,14 @@
|
||||
"id": "7b6d3d04-2844-4bf4-986c-503d62a39e84",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 拆分PD指定F页"
|
||||
"## 拆分PDF指定F页"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": null,
|
||||
"id": "664c3aca-74e3-4a07-a141-a1dde3ef96e2",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2021-11-08T12:51:27.262359Z",
|
||||
"iopub.status.busy": "2021-11-08T12:51:27.261120Z",
|
||||
"iopub.status.idle": "2021-11-08T12:52:40.868282Z",
|
||||
"shell.execute_reply": "2021-11-08T12:52:40.866331Z",
|
||||
"shell.execute_reply.started": "2021-11-08T12:51:27.262250Z"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pdfplumber\n",
|
||||
|
||||
Reference in new issue
Block a user