This commit is contained in:
512song committed 2023-05-25 19:17:38 +08:00
1 parent 91ae3fce79
commit 8242dc00aa
5 files changed
+745 -478

No files matched your search

+65 -30
View File
@@ -33,8 +33,6 @@
],
"source": [
"import json\n",
"import time\n",
"import csv\n",
"\n",
"filename = 'data/淄博交警体质指标问卷.json'\n",
"item = {}\n",
@@ -63,6 +61,58 @@
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "5eed4886-a332-429f-9283-e109d48227fe",
"metadata": {},
"source": [
"## 体质指标问卷整理"
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "857ca433-556a-4152-af7e-5f81434d11a7",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-22T13:35:16.464666Z",
"iopub.status.busy": "2023-05-22T13:35:16.463814Z",
"iopub.status.idle": "2023-05-22T13:35:16.476027Z",
"shell.execute_reply": "2023-05-22T13:35:16.474929Z",
"shell.execute_reply.started": "2023-05-22T13:35:16.464626Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import json\n",
"\n",
"filename = 'data/淄博交警体质问卷参数.json'\n",
"item = {}\n",
"unit = {}\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"for k, v in dict1.items():\n",
" if 'choices' in v.keys():\n",
" dict2 = {}\n",
" for item in v['choices']:\n",
" dict2[str(item['value'])] = item['text']\n",
" dict1[k]['choices'] = dict2\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": "d7ab7cfd-3448-45a6-abb4-04e7f317b843",
@@ -73,15 +123,15 @@
},
{
"cell_type": "code",
"execution_count": 33,
"id": "e05bb84b-e649-4201-95d7-f9fee7b1a254",
"execution_count": 43,
"id": "f5c6a39a-3e3e-4844-8ff8-b9ebb7e8f8af",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-22T09:31:19.028959Z",
"iopub.status.busy": "2023-05-22T09:31:19.028116Z",
"iopub.status.idle": "2023-05-22T09:31:19.043637Z",
"shell.execute_reply": "2023-05-22T09:31:19.042568Z",
"shell.execute_reply.started": "2023-05-22T09:31:19.028917Z"
"iopub.execute_input": "2023-05-22T13:36:57.660765Z",
"iopub.status.busy": "2023-05-22T13:36:57.660192Z",
"iopub.status.idle": "2023-05-22T13:36:57.673702Z",
"shell.execute_reply": "2023-05-22T13:36:57.672666Z",
"shell.execute_reply.started": "2023-05-22T13:36:57.660720Z"
},
"tags": []
},
@@ -156,9 +206,6 @@
],
"source": [
"import json\n",
"import time\n",
"import csv\n",
"\n",
"filename = 'data/淄博交警体质问卷参数.json'\n",
"item = {}\n",
"unit = {}\n",
@@ -166,8 +213,7 @@
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/Survey_20230522.json'\n",
"item = {}\n",
"unit = {}\n",
"\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"for items in dict2['Survey']:\n",
@@ -176,33 +222,22 @@
" print(phone)\n",
" data = json.loads(items['data'])\n",
" for k, v in data.items():\n",
" title = dict1[k]['title']\n",
" if dict1[k]['type'] == 'radiogroup':\n",
" title = dict1[k]['title']\n",
" for item in dict1[k]['choices']:\n",
" if item['value'] == v:\n",
" value = item['text']\n",
" \n",
" value = dict1[k]['choices'][str(v)] \n",
" if dict1[k]['type'] == 'text':\n",
" title = dict1[k]['title']\n",
" value = v\n",
" if dict1[k]['type'] == 'checkbox':\n",
" title = dict1[k]['title']\n",
" value = []\n",
" for choice in v:\n",
" for item in dict1[k]['choices']:\n",
" if item['value'] == choice:\n",
" value.append(item['text'])\n",
"\n",
" print(title,value) \n",
" \n",
" \n",
" "
" value.append(dict1[k]['choices'][str(choice)]) \n",
" print(title,value) "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f5c6a39a-3e3e-4844-8ff8-b9ebb7e8f8af",
"id": "2bb69139-b4be-4fd1-ae44-461f62b09503",
"metadata": {},
"outputs": [],
"source": []