20231117
This commit is contained in:
1 parent
066a903916
commit
a4f158504b
2 files changed
+274
-71
No files matched your search
+73
-71
@@ -4,6 +4,7 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "1c72f0cf-165b-4025-af9d-6771e4a0a5d1",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": [],
|
||||
"toc-hr-collapsed": true
|
||||
},
|
||||
@@ -15,7 +16,6 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "61f4a6eb-797e-4fe2-95df-e27b316c95f1",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
@@ -1063,12 +1063,28 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 100,
|
||||
"id": "1aa45b35-7376-4c50-8275-79b090a6c758",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-11-16T08:39:54.051678Z",
|
||||
"iopub.status.busy": "2023-11-16T08:39:54.051221Z",
|
||||
"iopub.status.idle": "2023-11-16T08:39:54.140085Z",
|
||||
"shell.execute_reply": "2023-11-16T08:39:54.139600Z",
|
||||
"shell.execute_reply.started": "2023-11-16T08:39:54.051641Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"697\n",
|
||||
"697\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import time\n",
|
||||
@@ -1183,9 +1199,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "63d5bccf-7351-4a08-863d-b1ca3b263eca",
|
||||
"execution_count": 101,
|
||||
"id": "c0128f52-8697-4258-aba0-89a522fb9cc0",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-11-16T08:39:58.488835Z",
|
||||
"iopub.status.busy": "2023-11-16T08:39:58.488433Z",
|
||||
"iopub.status.idle": "2023-11-16T08:39:58.584720Z",
|
||||
"shell.execute_reply": "2023-11-16T08:39:58.584247Z",
|
||||
"shell.execute_reply.started": "2023-11-16T08:39:58.488803Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
@@ -1204,47 +1227,58 @@
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict3 = json.load(fl)\n",
|
||||
"\n",
|
||||
"phone = set()\n",
|
||||
"phone1 = set()\n",
|
||||
"phone = {}\n",
|
||||
"for k,v in dict3.items():\n",
|
||||
" if 'phone' in v.keys():\n",
|
||||
" phone.add(v['phone'])\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,tcm,spine = []\n",
|
||||
"m_rq = '2023-11-14'\n",
|
||||
"rq= date.fromisoformat(m_rq.replace('/','-'))\n",
|
||||
"for item in list1:\n",
|
||||
" if item[2] in phone: \n",
|
||||
" content = json.loads(item[5])\n",
|
||||
"psy = []\n",
|
||||
"tcm = []\n",
|
||||
"spine = []\n",
|
||||
"\n",
|
||||
"for i in range(0,44):\n",
|
||||
" psy.append(0)\n",
|
||||
"for i in range(0,60):\n",
|
||||
" tcm.append(0)\n",
|
||||
"for i in range(0,26):\n",
|
||||
" spine.append(0)\n",
|
||||
"\n",
|
||||
"for item in list1:\n",
|
||||
" if item[2] in phone.keys(): \n",
|
||||
" content = json.loads(item[5])\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",
|
||||
" 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",
|
||||
" list2[i-1] = v\n",
|
||||
" dict2[item[2]] = list2\n",
|
||||
"print(dict2) \n",
|
||||
"for k, v in dict3.items():\n",
|
||||
" if 'phone' in v.keys() and v['phone'] in dict2.keys():\n",
|
||||
" if k not in dict1.keys():\n",
|
||||
" dict1.setdefault(k,{})\n",
|
||||
" dict1[k] = dict3[k]\n",
|
||||
" days = (v['rq']-v['birth']).days \n",
|
||||
" dict1[k]['age'] = int(days/365)\n",
|
||||
" dict1[k]['month'] = int(days/365*12)\n",
|
||||
" \n",
|
||||
" dict1[k]['tcm'] = dict2[str(v['phone'])]\n",
|
||||
" psy[i-1] = int(v)\n",
|
||||
" if 'tcm' in k:\n",
|
||||
" i = int(k[3:])\n",
|
||||
" tcm[i-1] = int(v)\n",
|
||||
" if 'spine' in k:\n",
|
||||
" i = int(k[5:])\n",
|
||||
" spine[i-1] = int(v)\n",
|
||||
" if 'psy' in item[5]:\n",
|
||||
" dict1[phone[item[2]]]['psy'] = psy\n",
|
||||
" if 'tcm' in item[5]:\n",
|
||||
" dict1[phone[item[2]]]['tcm'] = tcm\n",
|
||||
" if 'spine' in item[5]:\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",
|
||||
@@ -1254,7 +1288,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "c0128f52-8697-4258-aba0-89a522fb9cc0",
|
||||
"id": "5f222727-d5b4-481f-8f1c-bea74b35936b",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
@@ -1275,7 +1309,6 @@
|
||||
" 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",
|
||||
@@ -1285,50 +1318,19 @@
|
||||
" 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) "
|
||||
"for i in range(0,44):\n",
|
||||
" psy.append(0)\n",
|
||||
"for i in range(0,60):\n",
|
||||
" tcm.append(0)\n",
|
||||
"for i in range(0,26):\n",
|
||||
" spine.append(0)\n",
|
||||
"print(len(spine))"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
+201
@@ -2540,6 +2540,206 @@
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "5facc164-841c-4866-8a2c-2d54f72d6a0b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 导入网上问卷内容"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 279,
|
||||
"id": "35d1738a-1ec1-4764-bcbd-c1333fac6bfd",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-11-16T10:17:00.510134Z",
|
||||
"iopub.status.busy": "2023-11-16T10:17:00.509670Z",
|
||||
"iopub.status.idle": "2023-11-16T10:17:00.551276Z",
|
||||
"shell.execute_reply": "2023-11-16T10:17:00.549886Z",
|
||||
"shell.execute_reply.started": "2023-11-16T10:17:00.510096Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"['12167', 'ptv_022_sh', '', '边晓睿', '3145586', '{\"gender\":\"f\",\"psy1\":4,\"psy2\":4,\"psy3\":4,\"psy4\":4,\"psy5\":4,\"psy6\":4,\"psy7\":3,\"psy8\":4,\"psy9\":4,\"psy10\":4,\"psy11\":4,\"psy12\":3,\"psy13\":3,\"psy14\":2,\"psy15\":4,\"psy16\":3,\"psy17\":4,\"psy18\":3,\"psy19\":4,\"psy20\":4,\"psy21\":4,\"psy22\":4,\"psy23\":4,\"psy24\":4,\"psy25\":4,\"psy26\":4,\"psy27\":0,\"psy28\":0,\"psy29\":0,\"psy30\":1,\"psy31\":1,\"psy32\":0,\"psy33\":1,\"psy34\":0,\"psy35\":1,\"psy36\":1,\"psy37\":1,\"psy38\":0,\"psy39\":0,\"psy40\":0,\"psy41\":5,\"psy42\":5,\"psy43\":5,\"psy44\":5,\"tcm1\":1,\"tcm2\":4,\"tcm3\":3,\"tcm4\":2,\"tcm5\":3,\"tcm6\":4,\"tcm7\":2,\"tcm8\":5,\"tcm9\":2,\"tcm10\":2,\"tcm11\":4,\"tcm12\":1,\"tcm13\":4,\"tcm14\":1,\"tcm15\":5,\"tcm16\":2,\"tcm17\":1,\"tcm18\":4,\"tcm19\":3,\"tcm20\":1,\"tcm21\":1,\"tcm22\":3,\"tcm23\":1,\"tcm24\":4,\"tcm25\":2,\"tcm26\":5,\"tcm27\":3,\"tcm28\":5,\"tcm29\":4,\"tcm30\":2,\"tcm31\":5,\"tcm32\":1,\"tcm33\":1,\"tcm34\":1,\"tcm35\":1,\"tcm36\":5,\"tcm37\":3,\"tcm38\":2,\"tcm39\":5,\"tcm40\":2,\"tcm41\":1,\"tcm42\":3,\"tcm43\":1,\"tcm44\":3,\"tcm45\":1,\"tcm46\":5,\"tcm47\":5,\"tcm48\":2,\"tcm49\":2,\"tcm50\":3,\"tcm51\":2,\"tcm52\":2,\"tcm53\":1,\"tcm54\":3,\"tcm55\":2,\"tcm56\":2,\"tcm57\":2,\"tcm58\":1,\"tcm59\":1,\"tcm60\":3,\"spine1\":1,\"spine2\":1,\"spine3\":2,\"spine4\":1,\"spine5\":2,\"spine6\":2,\"spine7\":2,\"spine8\":2,\"spine9\":1,\"spine10\":2,\"spine11\":1,\"spine12\":2,\"spine13\":2,\"spine14\":2,\"spine15\":1,\"spine16\":1,\"spine17\":2,\"spine18\":2,\"spine19\":2,\"spine20\":2,\"spine21\":1,\"spine23\":2,\"spine24\":1,\"spine25\":2,\"spine26\":2}', '2023-11-13 14:25:18']\n",
|
||||
"['12168', 'ptv_022_sh', '', '孙海红', '1733738', '{\"gender\":\"f\",\"psy1\":3,\"psy2\":3,\"psy3\":2,\"psy4\":3,\"psy5\":3,\"psy6\":4,\"psy7\":3,\"psy8\":3,\"psy9\":4,\"psy10\":3,\"psy11\":4,\"psy12\":4,\"psy13\":3,\"psy14\":3,\"psy15\":3,\"psy16\":4,\"psy17\":4,\"psy18\":4,\"psy19\":4,\"psy20\":4,\"psy21\":3,\"psy22\":4,\"psy23\":4,\"psy24\":4,\"psy25\":4,\"psy26\":4,\"psy27\":0,\"psy28\":0,\"psy29\":0,\"psy30\":0,\"psy31\":0,\"psy32\":0,\"psy33\":1,\"psy34\":1,\"psy35\":0,\"psy36\":0,\"psy37\":0,\"psy38\":0,\"psy39\":0,\"psy40\":1,\"psy41\":4,\"psy42\":4,\"psy43\":4,\"psy44\":4,\"tcm1\":2,\"tcm2\":4,\"tcm3\":4,\"tcm4\":3,\"tcm5\":1,\"tcm6\":3,\"tcm7\":1,\"tcm8\":4,\"tcm9\":1,\"tcm10\":1,\"tcm11\":4,\"tcm12\":3,\"tcm13\":4,\"tcm14\":1,\"tcm15\":3,\"tcm16\":3,\"tcm17\":3,\"tcm18\":3,\"tcm19\":3,\"tcm20\":3,\"tcm21\":2,\"tcm22\":2,\"tcm23\":2,\"tcm24\":1,\"tcm25\":1,\"tcm26\":1,\"tcm27\":3,\"tcm28\":1,\"tcm29\":3,\"tcm30\":2,\"tcm31\":2,\"tcm32\":2,\"tcm33\":2,\"tcm34\":3,\"tcm35\":5,\"tcm36\":3,\"tcm37\":2,\"tcm38\":2,\"tcm39\":2,\"tcm40\":1,\"tcm41\":2,\"tcm42\":1,\"tcm43\":1,\"tcm44\":3,\"tcm45\":3,\"tcm46\":3,\"tcm47\":2,\"tcm49\":2,\"tcm50\":2,\"tcm48\":2,\"tcm51\":2,\"tcm52\":2,\"tcm53\":3,\"tcm54\":3,\"tcm55\":1,\"tcm56\":1,\"tcm57\":1,\"tcm58\":2,\"tcm59\":1,\"tcm60\":5,\"spine1\":2,\"spine2\":1,\"spine3\":1,\"spine4\":1,\"spine5\":2,\"spine6\":2,\"spine7\":2,\"spine8\":2,\"spine9\":1,\"spine10\":2,\"spine11\":2,\"spine12\":2,\"spine13\":2,\"spine14\":2,\"spine15\":2,\"spine16\":2,\"spine17\":2,\"spine18\":2,\"spine19\":1,\"spine20\":2,\"spine21\":2,\"spine23\":2,\"spine24\":1,\"spine25\":1,\"spine26\":2}', '2023-11-13 14:32:18']\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
"import openpyxl\n",
|
||||
"import time\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"dict1 = {}\n",
|
||||
"\n",
|
||||
"filename = 'data/天津石化人员名单2023.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict3 = json.load(fl)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/Survey_20231116.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",
|
||||
" list1.append(line)\n",
|
||||
"#print(list1)\n",
|
||||
"dict2 = {}\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"for item in list1:\n",
|
||||
" psy = []\n",
|
||||
" tcm = []\n",
|
||||
" spine = []\n",
|
||||
" for i in range(0,45):\n",
|
||||
" psy.append(0)\n",
|
||||
" for i in range(0,60):\n",
|
||||
" tcm.append(0)\n",
|
||||
" for i in range(0,26):\n",
|
||||
" spine.append(0)\n",
|
||||
" print(item)\n",
|
||||
" content = json.loads(item[5])\n",
|
||||
" if str(item[4]) not in dict1.keys():\n",
|
||||
" dict1[str(item[4])] = dict3[str(item[4])]\n",
|
||||
" rq = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
|
||||
" #dict1[phone[item[2]]]['rq'] = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
|
||||
" for k, v in content.items():\n",
|
||||
" if 'psy' in k:\n",
|
||||
" i = int(k[3:])\n",
|
||||
" psy[i-1] = int(v)\n",
|
||||
" if 'tcm' in k:\n",
|
||||
" i = int(k[3:])\n",
|
||||
" tcm[i-1] = int(v)\n",
|
||||
" if 'spine' in k:\n",
|
||||
" i = int(k[5:])\n",
|
||||
" spine[i-1] = int(v)\n",
|
||||
" if 'psy' in item[5]:\n",
|
||||
" for i in range(5,26):\n",
|
||||
" new_valve = 5-psy[i]\n",
|
||||
" psy[i] = new_valve\n",
|
||||
" for i in range(26,40):\n",
|
||||
" new_valve = 1+psy[i]\n",
|
||||
" psy[i] = new_valve\n",
|
||||
" psy[44] = []\n",
|
||||
" dict1[str(item[4])]['psy'] = psy\n",
|
||||
" if 'tcm' in item[5]:\n",
|
||||
" dict1[str(item[4])]['tcm'] = tcm\n",
|
||||
" if 'spine' in item[5]:\n",
|
||||
" dict1[str(item[4])]['spine'] = spine\n",
|
||||
" birth = date.fromisoformat(dict3[str(item[4])]['birth'].replace('/','-'))\n",
|
||||
"\n",
|
||||
" days = (rq-birth).days \n",
|
||||
" dict1[str(item[4])]['age'] = int(days/365)\n",
|
||||
" dict1[str(item[4])]['month'] = int(days/365*12)\n",
|
||||
"#print(dict1)\n",
|
||||
"filename = 'data/result_天津问卷.json'\n",
|
||||
"\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict1, fl, ensure_ascii=False) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d842c189-dcc2-4e31-9bc2-e272c929e6af",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 280,
|
||||
"id": "cc9e1717-f445-49a9-a770-c103da603434",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-11-16T10:18:15.998767Z",
|
||||
"iopub.status.busy": "2023-11-16T10:18:15.998303Z",
|
||||
"iopub.status.idle": "2023-11-16T10:18:16.660154Z",
|
||||
"shell.execute_reply": "2023-11-16T10:18:16.658708Z",
|
||||
"shell.execute_reply.started": "2023-11-16T10:18:15.998730Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"3145586 边晓睿 {\"errmsg\":\"ok\"}\n",
|
||||
"1733738 孙海红 {\"errmsg\":\"ok\"}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"import json\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"headers = {\n",
|
||||
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
||||
" }\n",
|
||||
"filename = 'data/result_天津问卷.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = []\n",
|
||||
"fiie_path ='./政法委1/'\n",
|
||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||||
"i = 27\n",
|
||||
"list2 = []\n",
|
||||
"#list1 = []\n",
|
||||
"for k,v in dict1.items(): \n",
|
||||
" list1 = []\n",
|
||||
" mydata = {} \n",
|
||||
" id = k.rjust(3,\"0\")\n",
|
||||
" mydata['path'] = fiie_path+id+'-'+ v['name']+'.pdf'\n",
|
||||
" mydata['title'] = '中石化(天津)石油化工\\n有限公司'\n",
|
||||
" #mydata['subtitle'] = ''\n",
|
||||
" mydata['id'] = id\n",
|
||||
" mydata['name'] = v['name']\n",
|
||||
" if v['sex'] == '男':\n",
|
||||
" mydata['gender'] = 'male'\n",
|
||||
" else:\n",
|
||||
" mydata['gender'] = 'female' \n",
|
||||
" mydata['month'] = v['month']\n",
|
||||
" \n",
|
||||
" if 'tcm' in v.keys():\n",
|
||||
" mydata.setdefault('surveys',{})\n",
|
||||
" mydata['surveys']['tcm'] = v['tcm']\n",
|
||||
" if 'psy' in v.keys():\n",
|
||||
" mydata.setdefault('surveys',{})\n",
|
||||
" mydata['surveys']['psy'] = v['psy']\n",
|
||||
" if 'tcm' in v.keys():\n",
|
||||
" mydata.setdefault('surveys',{})\n",
|
||||
" mydata['surveys']['spine'] = v['spine']\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" \n",
|
||||
" list1.append(mydata)\n",
|
||||
" #list2.append([k,dict1[k]['name']])\n",
|
||||
"\n",
|
||||
" x = requests.post('http://localhost:3003', data = json.dumps(list1), headers=headers)\n",
|
||||
" print(id,dict1[k]['name'],x.text)\n",
|
||||
" x.close()\n",
|
||||
" #print(mydata)\n",
|
||||
"#filename = 'data/data_天津问卷.json'\n",
|
||||
"\n",
|
||||
"#with open(filename,'w') as fl:\n",
|
||||
"# json.dump(list1, fl, ensure_ascii=False) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "85a03b00-9624-4ae9-aa6d-386798d457df",
|
||||
@@ -2551,6 +2751,7 @@
|
||||
"shell.execute_reply": "2023-10-25T02:50:57.004773Z",
|
||||
"shell.execute_reply.started": "2023-10-25T02:50:56.997463Z"
|
||||
},
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
|
||||
Reference in new issue
Block a user