This commit is contained in:
512song committed 2021-10-26 22:03:56 +08:00
1 parent 493d0f79c2
commit 8b780a6e66
1 file changed
+73 -3
+73 -3
View File
@@ -752,12 +752,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "9e33d1bc-1b71-47f7-928a-16ec435449d6",
"metadata": {
"execution": {
"iopub.execute_input": "2021-10-26T08:21:04.983764Z",
"iopub.status.busy": "2021-10-26T08:21:04.982673Z",
"iopub.status.idle": "2021-10-26T08:21:09.421348Z",
"shell.execute_reply": "2021-10-26T08:21:09.419179Z",
"shell.execute_reply.started": "2021-10-26T08:21:04.983506Z"
},
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
@@ -790,10 +805,65 @@
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "f9e61ba9-38f8-4b61-bf1e-4e7bbde4f32c",
"metadata": {},
"source": [
"## 心理健康量表统计导入"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "2475a1c3-c2e7-45d6-9685-32e28e606df5",
"metadata": {
"execution": {
"iopub.execute_input": "2021-10-26T13:02:51.590980Z",
"iopub.status.busy": "2021-10-26T13:02:51.590050Z",
"iopub.status.idle": "2021-10-26T13:02:52.262203Z",
"shell.execute_reply": "2021-10-26T13:02:52.260218Z",
"shell.execute_reply.started": "2021-10-26T13:02:51.590874Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"wb = openpyxl.load_workbook('file/北海炼化公司职工心理健康量表统计.xlsx')\n",
"sheet = wb.active\n",
"#sheets = wb.sheetnames\n",
"dict1 = {}\n",
"for n in range(2,sheet.max_row+1):\n",
" mdm = sheet.cell(n,1).value\n",
" dict1.setdefault(mdm,{})\n",
" dict2 = {}\n",
" list1 = [1,2,3,4,5,None]\n",
" for i in range(2,42):\n",
" #if sheet.cell(n,i).value not in list1:\n",
" dict2[i-1] = sheet.cell(n,i).value\n",
" #print(f'error!{mdm}--{sheet.cell(n,i).value}')\n",
" dict1[mdm] = dict2\n",
"filename = '北海炼化公司职工心理健康量表统计.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl,ensure_ascii=False) \n",
"print('ok')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "607638c1-9cfe-442a-9823-3b506ce04db6",
"id": "671d6afe-5ed2-404e-bd8c-df3118ea3743",
"metadata": {},
"outputs": [],
"source": []