20241206
This commit is contained in:
1 parent
9c40a2b9f7
commit
1da757e355
5 files changed
+715
-646
No files matched your search
+212
-29
@@ -636,7 +636,6 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "c103301b-d540-4bf5-861a-0eb2e313e26e",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
@@ -2183,15 +2182,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"execution_count": 35,
|
||||
"id": "e1a1b329-acf1-4be9-bcf0-736dbe7f8e0b",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-04T14:53:01.181252Z",
|
||||
"iopub.status.busy": "2024-12-04T14:53:01.180490Z",
|
||||
"iopub.status.idle": "2024-12-04T14:53:01.243823Z",
|
||||
"shell.execute_reply": "2024-12-04T14:53:01.243252Z",
|
||||
"shell.execute_reply.started": "2024-12-04T14:53:01.181166Z"
|
||||
"iopub.execute_input": "2024-12-06T06:33:02.890686Z",
|
||||
"iopub.status.busy": "2024-12-06T06:33:02.889945Z",
|
||||
"iopub.status.idle": "2024-12-06T06:33:02.953794Z",
|
||||
"shell.execute_reply": "2024-12-06T06:33:02.953311Z",
|
||||
"shell.execute_reply.started": "2024-12-06T06:33:02.890614Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -2267,9 +2266,17 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 36,
|
||||
"id": "17ebb0fd-9a45-47a4-bbe9-f4fb0a3481f6",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-06T06:33:08.201679Z",
|
||||
"iopub.status.busy": "2024-12-06T06:33:08.200968Z",
|
||||
"iopub.status.idle": "2024-12-06T06:33:08.367295Z",
|
||||
"shell.execute_reply": "2024-12-06T06:33:08.366715Z",
|
||||
"shell.execute_reply.started": "2024-12-06T06:33:08.201614Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
@@ -2330,15 +2337,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 32,
|
||||
"execution_count": 37,
|
||||
"id": "dd89efe8-13b9-4db8-8c39-2a48888dd635",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-04T14:53:17.474923Z",
|
||||
"iopub.status.busy": "2024-12-04T14:53:17.474146Z",
|
||||
"iopub.status.idle": "2024-12-04T14:53:18.915899Z",
|
||||
"shell.execute_reply": "2024-12-04T14:53:18.915258Z",
|
||||
"shell.execute_reply.started": "2024-12-04T14:53:17.474853Z"
|
||||
"iopub.execute_input": "2024-12-06T06:34:03.871370Z",
|
||||
"iopub.status.busy": "2024-12-06T06:34:03.870707Z",
|
||||
"iopub.status.idle": "2024-12-06T06:34:05.280791Z",
|
||||
"shell.execute_reply": "2024-12-06T06:34:05.280240Z",
|
||||
"shell.execute_reply.started": "2024-12-06T06:34:03.871312Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -2386,6 +2393,119 @@
|
||||
"print('ok!') "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b57447d9-ac3c-47c2-9592-3878c6845918",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 导入问卷"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 43,
|
||||
"id": "9563c47b-94e4-44f7-98e1-7d284ad3841c",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-06T13:25:18.037788Z",
|
||||
"iopub.status.busy": "2024-12-06T13:25:18.037123Z",
|
||||
"iopub.status.idle": "2024-12-06T13:25:18.169186Z",
|
||||
"shell.execute_reply": "2024-12-06T13:25:18.168612Z",
|
||||
"shell.execute_reply.started": "2024-12-06T13:25:18.037728Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
"import openpyxl\n",
|
||||
"import time\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"filename = 'data/result_北海炼化2024.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"\n",
|
||||
"filename = 'data/北海炼化人员2024.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict3 = json.load(fl)\n",
|
||||
"\n",
|
||||
"phone = {}\n",
|
||||
"for k,v in dict3.items():\n",
|
||||
" if 'phone' in v.keys():\n",
|
||||
" phone[v['phone']] = k\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/Survey_20241206.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",
|
||||
"psy =[]\n",
|
||||
"tcm = []\n",
|
||||
"spine = []\n",
|
||||
"for i in range(0,45):\n",
|
||||
" psy.append(0)\n",
|
||||
"psy[44] = []\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",
|
||||
" psy =[]\n",
|
||||
" tcm = []\n",
|
||||
" spine = []\n",
|
||||
" for i in range(0,45):\n",
|
||||
" psy.append(0)\n",
|
||||
" psy[44] = []\n",
|
||||
" for i in range(0,60):\n",
|
||||
" tcm.append(0)\n",
|
||||
" for i in range(0,26):\n",
|
||||
" spine.append(0)\n",
|
||||
" \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-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",
|
||||
" \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_北海炼化2024.json'\n",
|
||||
"\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict1, fl, ensure_ascii=False) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "378982cd-8f4a-4b61-a87c-a138eb891342",
|
||||
@@ -2396,10 +2516,26 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 47,
|
||||
"id": "a1a12409-aab8-47af-b10d-7ecb20b3b332",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-06T13:41:57.576034Z",
|
||||
"iopub.status.busy": "2024-12-06T13:41:57.575284Z",
|
||||
"iopub.status.idle": "2024-12-06T13:41:57.808661Z",
|
||||
"shell.execute_reply": "2024-12-06T13:41:57.808089Z",
|
||||
"shell.execute_reply.started": "2024-12-06T13:41:57.575964Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
@@ -2419,11 +2555,10 @@
|
||||
" list2.append(dict1[k]['name']) \n",
|
||||
" list2.append(dict1[k]['sex'])\n",
|
||||
" list2.append(dict1[k]['unit'])\n",
|
||||
" #list2.append(dict1[k]['phone'])\n",
|
||||
" i = 0\n",
|
||||
" if 'bmi' in dict1[k].keys():\n",
|
||||
" list2.append(dict1[k]['height']['成绩'])\n",
|
||||
" list2.append(dict1[k]['weight']['成绩'])\n",
|
||||
" list2.append(dict1[k]['bmi']['成绩'].split(',')[0])\n",
|
||||
" list2.append(dict1[k]['bmi']['成绩'].split(',')[1])\n",
|
||||
" list2.append(dict1[k]['bmi']['score'])\n",
|
||||
" i+=1\n",
|
||||
" else:\n",
|
||||
@@ -2444,7 +2579,7 @@
|
||||
" list2.append('') \n",
|
||||
" if i>2:\n",
|
||||
" list1.append(list2)\n",
|
||||
"filename = 'data/北海炼化体测情况表.xlsx'\n",
|
||||
"filename = 'data/北海炼化体测情况明细表(2024年).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"sheet.append(title)\n",
|
||||
@@ -2567,15 +2702,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"execution_count": 39,
|
||||
"id": "6d8a345d-39e0-40cd-9bed-ac4e144b426c",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-04T15:01:40.945578Z",
|
||||
"iopub.status.busy": "2024-12-04T15:01:40.944820Z",
|
||||
"iopub.status.idle": "2024-12-04T15:01:40.998222Z",
|
||||
"shell.execute_reply": "2024-12-04T15:01:40.997687Z",
|
||||
"shell.execute_reply.started": "2024-12-04T15:01:40.945506Z"
|
||||
"iopub.execute_input": "2024-12-06T07:47:19.162940Z",
|
||||
"iopub.status.busy": "2024-12-06T07:47:19.162185Z",
|
||||
"iopub.status.idle": "2024-12-06T07:47:19.214132Z",
|
||||
"shell.execute_reply": "2024-12-06T07:47:19.213530Z",
|
||||
"shell.execute_reply.started": "2024-12-06T07:47:19.162868Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -2655,8 +2790,56 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 58,
|
||||
"id": "6cba8d5e-92fd-4afd-94d2-0dcf42e2e22e",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-12-06T14:55:55.316383Z",
|
||||
"iopub.status.busy": "2024-12-06T14:55:55.315888Z",
|
||||
"iopub.status.idle": "2024-12-06T14:55:55.397708Z",
|
||||
"shell.execute_reply": "2024-12-06T14:55:55.397100Z",
|
||||
"shell.execute_reply.started": "2024-12-06T14:55:55.316334Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"757\n",
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = 'data/result_北海炼化2024.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list2 = []\n",
|
||||
"for k,v in dict1.items():\n",
|
||||
" #list2 = []\n",
|
||||
" list2.append([k,v['name'],v['sex'],v['age'],v['unit']])\n",
|
||||
" \n",
|
||||
"filename = 'data/北海人员基本情况2024.xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"\n",
|
||||
"for row in list2:\n",
|
||||
" sheet.append(row)\n",
|
||||
" \n",
|
||||
"wb.save(filename)\n",
|
||||
"print(len(dict1))\n",
|
||||
"print('ok') "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "712572b1-7a9b-4022-93de-13166508a307",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
|
||||
Reference in new issue
Block a user