diff --git a/体测单位/低碳院.ipynb b/体测单位/低碳院.ipynb index 233cad1..e57093a 100644 --- a/体测单位/低碳院.ipynb +++ b/体测单位/低碳院.ipynb @@ -446,30 +446,12 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "dfa3f093-25a7-4a8d-b4d6-22e0f6fcbb92", "metadata": { - "execution": { - "iopub.execute_input": "2023-03-13T11:16:03.723835Z", - "iopub.status.busy": "2023-03-13T11:16:03.722922Z", - "iopub.status.idle": "2023-03-13T11:16:03.822603Z", - "shell.execute_reply": "2023-03-13T11:16:03.821845Z", - "shell.execute_reply.started": "2023-03-13T11:16:03.723794Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 郝国政 18813095526 501\n", - "2 杜鹏 15910618307 506\n", - "3 魏垚 18765506895 232\n", - "4 赵亮亮 18610066890 507\n" - ] - } - ], + "outputs": [], "source": [ "import openpyxl\n", "import math\n", @@ -515,28 +497,12 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "8ccee97e-60e0-4363-b706-d4a71f214142", "metadata": { - "execution": { - "iopub.execute_input": "2023-03-13T11:40:04.102953Z", - "iopub.status.busy": "2023-03-13T11:40:04.102098Z", - "iopub.status.idle": "2023-03-13T11:40:04.275805Z", - "shell.execute_reply": "2023-03-13T11:40:04.274943Z", - "shell.execute_reply.started": "2023-03-13T11:40:04.102912Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "15210715398\n", - "13810886698\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import pymysql\n", @@ -589,33 +555,22 @@ "### 统计2022年问卷人员信息" ] }, + { + "cell_type": "markdown", + "id": "1ddcc50e-f6b5-4fcc-8bb4-64ebb1d6f9e3", + "metadata": {}, + "source": [ + "#### 统计2022年问卷人员总信息" + ] + }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "2339b885-e885-499a-a078-5a2a1fb818bd", "metadata": { - "execution": { - "iopub.execute_input": "2023-03-13T12:25:35.400570Z", - "iopub.status.busy": "2023-03-13T12:25:35.399705Z", - "iopub.status.idle": "2023-03-13T12:25:35.531463Z", - "shell.execute_reply": "2023-03-13T12:25:35.530708Z", - "shell.execute_reply.started": "2023-03-13T12:25:35.400529Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "15210715398\n", - "15006594388\n", - "15210715398\n", - "17326968610\n", - "17326968610\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import pymysql\n", @@ -660,10 +615,311 @@ " print(item)\n" ] }, + { + "cell_type": "markdown", + "id": "fc57ad21-a1d1-4728-8997-016fd72cbdc8", + "metadata": {}, + "source": [ + "#### 核验人员手机号码重复" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "69300248-e60f-4086-9eb9-2a61e91b5957", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-15T00:20:11.350101Z", + "iopub.status.busy": "2023-03-15T00:20:11.349391Z", + "iopub.status.idle": "2023-03-15T00:20:11.509018Z", + "shell.execute_reply": "2023-03-15T00:20:11.508290Z", + "shell.execute_reply.started": "2023-03-15T00:20:11.350074Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "import json\n", + "import pymysql\n", + "import openpyxl\n", + "\n", + "\n", + "dict1 = {}\n", + "dict2 = {}\n", + "dict3 = {}\n", + "list1 = []\n", + "fi_xls = 'data/低碳院人员信息表.xlsx'\n", + "wb = openpyxl.load_workbook(fi_xls)\n", + "sheet = wb.active\n", + "for n in range(2,sheet.max_row+1):\n", + " if sheet.cell(n,2).value is not None:\n", + " pn = str(sheet.cell(n,7).value).strip()\n", + " if pn not in list1:\n", + " list1.append(pn)\n", + " else:\n", + " print(pn)\n", + " " + ] + }, { "cell_type": "code", "execution_count": null, - "id": "30704310-351a-406d-a0fe-02a5cefe6012", + "id": "9d5cbdcf-7f46-4a51-a695-258eb0273d2a", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import json\n", + "import pymysql\n", + "import openpyxl\n", + "\n", + "\n", + "dict1 = {}\n", + "dict2 = {}\n", + "dict3 = {}\n", + "list1 = []\n", + "sql = \"SELECT a.phone,a.name,c.unit FROM people as a,places_people as b,_ditan2 as c WHERE a.id =b.people_id AND c.id = b.avatar_id and b.place_id = 139\"\n", + "cursor.execute(sql)\n", + "results = cursor.fetchall()\n", + "for result in results:\n", + " if result[0] not in list1:\n", + " list1.append(result[0])\n", + " else:\n", + " print(result[0])\n", + "print(list1)" + ] + }, + { + "cell_type": "markdown", + "id": "1afcf98f-1965-46a9-b549-5dbabcb9a440", + "metadata": {}, + "source": [ + "#### 统计2022年心理问卷人员" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ca716a71-d866-413c-bf66-204003cc019a", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import json\n", + "import pymysql\n", + "import openpyxl\n", + "\n", + "\n", + "dict1 = {}\n", + "dict2 = {}\n", + "dict3 = {}\n", + "list1 = []\n", + "sql = \"SELECT a.phone,a.name,c.unit FROM people as a,places_people as b,_ditan2 as c WHERE a.id =b.people_id AND c.id = b.avatar_id and b.place_id = 139\"\n", + "cursor.execute(sql)\n", + "results = cursor.fetchall()\n", + "\n", + "for result in results:\n", + " if result[0] != None:\n", + " dict1[result[0]] = [result[1],result[2]]\n", + "#print(dict1)\n", + "\n", + "sql = \"select * FROM Survey s WHERE s.surveyId IN ('psy4','tcmv2') AND s.updatedAt >'2022-11-01'\"\n", + "cursor.execute(sql)\n", + "results = cursor.fetchall()\n", + "for result in results: \n", + " #dict2[result[0]] = [str(result[2]).strip(),result[6]]\n", + " pn = str(result[2]).strip()\n", + " if pn in dict1.keys():\n", + " dict2.setdefault(pn,{})\n", + " dict2[pn].setdefault('item',[])\n", + " dict2[pn]['name'] = dict1[pn][0]\n", + " dict2[pn]['unit'] = dict1[pn][1]\n", + " dict2[pn]['item'].append(result[1])\n", + "#print(dict2)\n", + "for k, v in dict2.items():\n", + " list2 = []\n", + " ph = k\n", + " item = ','.join(v['item'])\n", + " name = v['name']\n", + " unit = v['unit']\n", + " list2 = [name,unit,ph,item]\n", + " list1.append(list2)\n", + "filename = 'data/北京低碳院问卷参与情况表.xlsx'\n", + "wb = openpyxl.Workbook()\n", + "sheet = wb.active\n", + "#sheet.append(title)\n", + "for row in list1:\n", + " sheet.append(row)\n", + " \n", + "wb.save(filename) \n", + " " + ] + }, + { + "cell_type": "markdown", + "id": "d3c7b93b-d132-4de4-a4f1-687b36d06b6d", + "metadata": {}, + "source": [ + "### 统计2023年体测人员邮箱信息" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "366a9875-3489-48fd-ba73-f19e106696a2", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import openpyxl\n", + "import math\n", + "import json\n", + "import pymysql\n", + "\n", + "fi_xls = 'data/低碳院人员信息表.xlsx'\n", + "chongming = ['王锐','王楠','郭强','王涛','张静']\n", + "dict1 = {}\n", + "dict2 = {}\n", + "dict3 = {}\n", + "\n", + "db = pymysql.connect(host = \"localhost\",user = \"songyi\",password = \"yylzs\",database = \"ydyb\" )\n", + "cursor = db.cursor()\n", + "sql = \"SELECT a.name ,a.phone,b.avatar_id FROM people as a,places_people as b WHERE a.id =b.people_id AND b.place_id = 139\"\n", + "cursor.execute(sql)\n", + "results = cursor.fetchall()\n", + "for result in results:\n", + " if result[0] not in chongming:\n", + " dict2[result[0]] = [str(result[1]).strip(),result[2]]\n", + "#print(dict2)\n", + "wb = openpyxl.load_workbook(fi_xls)\n", + "sheet = wb.active\n", + "for n in range(2,sheet.max_row+1):\n", + " if sheet.cell(n,2).value is not None:\n", + " email = str(sheet.cell(n,6).value).strip()\n", + " name = str(sheet.cell(n,2).value).strip()\n", + " if name in dict2.keys():\n", + " bh = dict2[name][1]\n", + " dict1.setdefault(bh,{})\n", + " dict1[bh]['name'] = name\n", + " dict1[bh]['phone'] = dict2[name][0]\n", + " dict1[bh]['email'] = email\n", + "print(dict1)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "a679a299-e338-42d3-b54e-443e834def72", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-15T00:40:07.365729Z", + "iopub.status.busy": "2023-03-15T00:40:07.364694Z", + "iopub.status.idle": "2023-03-15T00:40:07.505094Z", + "shell.execute_reply": "2023-03-15T00:40:07.504364Z", + "shell.execute_reply.started": "2023-03-15T00:40:07.365688Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "47 张静\n", + "58 张静\n", + "109 王涛\n", + "209 王锐\n", + "228 王锐\n", + "273 王楠\n", + "378 郭强\n", + "408 王涛\n", + "433 王楠\n", + "465 郭强\n", + "494 王永涛\n", + "495 杨靖\n", + "496 李晓宝\n", + "497 王婧\n", + "498 徐滨\n", + "499 孙华宇\n", + "500 贾建慧\n", + "501 郝国政\n", + "502 崔双双\n", + "503 赵振慧\n", + "504 刘静远\n", + "505 陆斌\n", + "506 杜鹏\n", + "507 赵亮亮\n", + "508 张文秀\n", + "ok\n" + ] + } + ], + "source": [ + "import openpyxl\n", + "import math\n", + "import json\n", + "import pymysql\n", + "\n", + "fi_xls = 'data/低碳院人员信息表.xlsx'\n", + "chongming = ['王锐','王楠','郭强','王涛','张静']\n", + "dict1 = {}\n", + "dict2 = {}\n", + "dict3 = {}\n", + "\n", + "db = pymysql.connect(host = \"localhost\",user = \"songyi\",password = \"yylzs\",database = \"ydyb\" )\n", + "cursor = db.cursor()\n", + "sql = \"SELECT a.name ,a.phone,b.avatar_id FROM people as a,places_people as b WHERE a.id =b.people_id AND b.place_id = 139\"\n", + "cursor.execute(sql)\n", + "results = cursor.fetchall()\n", + "for result in results:\n", + " bh = result[2]\n", + " dict2.setdefault(bh,{})\n", + "\n", + " dict2[bh]['name'] = str(result[0]).strip()\n", + " if result[1] is not None:\n", + " dict2[bh]['phone'] = str(result[1]).strip()\n", + "#print(dict2)\n", + "wb = openpyxl.load_workbook(fi_xls)\n", + "sheet = wb.active\n", + "for n in range(2,sheet.max_row+1):\n", + " if sheet.cell(n,2).value not in chongming:\n", + " email = str(sheet.cell(n,6).value).strip()\n", + " name = str(sheet.cell(n,2).value).strip()\n", + " dict1[name] = email\n", + "for k, v in dict2.items():\n", + " if v['name'] in dict1.keys():\n", + " dict2[k]['email'] = dict1[v['name']]\n", + "#for k, v in dict2.items():\n", + "# if 'email' not in v.keys():\n", + "# print(k,v['name'])\n", + "for n in range(2,sheet.max_row+1):\n", + " email = str(sheet.cell(n,6).value).strip()\n", + " name = str(sheet.cell(n,2).value).strip()\n", + " pn = str(sheet.cell(n,7).value).strip()\n", + " dict3.setdefault(pn,{})\n", + " dict3[pn]['email'] = email\n", + " dict3[pn]['name'] = name\n", + "\n", + "for k, v in dict2.items():\n", + " if 'phone' in v.keys() and v['phone'] in dict3.keys() and v['name'] == dict3[v['phone']]['name']:\n", + " dict2[k]['email'] = dict3[v['phone']]['email']\n", + "\n", + "#for k, v in dict2.items():\n", + "# if 'email' not in v.keys():\n", + "# print(k,v['name'],v['phone'])\n", + "filename = 'data/低碳院邮件信息.json'\n", + "with open(filename, 'w') as fl:\n", + " json.dump(dict2, fl, ensure_ascii=False)\n", + "print('ok')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "621624d7-7e9e-4309-b6d1-a9dcfc5a888a", "metadata": {}, "outputs": [], "source": []