950 lines
28 KiB
Plaintext
950 lines
28 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "4b749231-7ab9-4dcd-8cfd-7b9be485d3c6",
|
|
"metadata": {
|
|
"jp-MarkdownHeadingCollapsed": true,
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"## 低碳院人员信息对应关系及导出"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "1a52629c-52b3-47ee-9796-9db0befc5140",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import os,sys,shutil\n",
|
|
"import openpyxl\n",
|
|
"import math\n",
|
|
"import json\n",
|
|
"\n",
|
|
"fi_xls = 'data/北京低碳监测.xlsx'\n",
|
|
"old = []\n",
|
|
"dict1 = {}\n",
|
|
"dict2 = {}\n",
|
|
"dict3 = {}\n",
|
|
"wb = openpyxl.load_workbook(fi_xls)\n",
|
|
"sheet = wb.active\n",
|
|
"depart = []\n",
|
|
"for n in range(2,sheet.max_row+1): \n",
|
|
" m_name = sheet.cell(n,6).value\n",
|
|
" m_depart = sheet.cell(n,3).value\n",
|
|
" if sheet.cell(n,4).value is not None:\n",
|
|
" dict1[int(sheet.cell(n,4).value)] = [m_name,m_depart]\n",
|
|
"fi_xls = 'data/低碳院人员邮件信息.xlsx'\n",
|
|
"\n",
|
|
"wb = openpyxl.load_workbook(fi_xls)\n",
|
|
"sheet = wb.active\n",
|
|
"for n in range(2,sheet.max_row+1): \n",
|
|
" m_dm = sheet.cell(n,3).value\n",
|
|
" m_depart = sheet.cell(n,2).value\n",
|
|
" m_name = sheet.cell(n,4).value\n",
|
|
" m_email = sheet.cell(n,3).value+sheet.cell(n,6).value\n",
|
|
"\n",
|
|
" if sheet.cell(n,3).value is not None:\n",
|
|
" dict2[sheet.cell(n,3).value] = [m_name,m_depart,m_email]\n",
|
|
"#print(dict2)\n",
|
|
"for item in dict1.keys():\n",
|
|
" old.append(item)\n",
|
|
"old.sort()\n",
|
|
"\n",
|
|
"for n in old:\n",
|
|
" m_name = dict1[n][0]\n",
|
|
" m_depart = dict1[n][1]\n",
|
|
" for item in dict2.values():\n",
|
|
" if m_name in item and m_depart in item:\n",
|
|
" dict3[int(n)] = [m_name,m_depart,item[2]]\n",
|
|
" break\n",
|
|
"dict3[232] = ['王锐','新能源技术研究中心','20063984@ceic.com']\n",
|
|
"dict3[213] = ['王锐','新能源技术研究中心','17240222@ceic.com']\n",
|
|
"\n",
|
|
"fi_xls = 'data/汇总表.xlsx'\n",
|
|
"\n",
|
|
"wb = openpyxl.load_workbook(fi_xls)\n",
|
|
"sheet = wb.active\n",
|
|
"for n in range(2,sheet.max_row+1): \n",
|
|
" m_dm = int(sheet.cell(n,1).value)\n",
|
|
" m_pn = sheet.cell(n,6).value\n",
|
|
" m_xb = sheet.cell(n,3).value\n",
|
|
" m_birth = sheet.cell(n,4).value\n",
|
|
" if sheet.cell(n,1).value is not None:\n",
|
|
" dict3[m_dm].append(m_xb)\n",
|
|
" dict3[m_dm].append(m_birth)\n",
|
|
" dict3[m_dm].append(m_pn)\n",
|
|
"#print(dict2)\n",
|
|
"\n",
|
|
"with open('data/低碳院人员信息.json','w') as fl2:\n",
|
|
" json.dump(dict3,fl2,ensure_ascii=False) "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "2494ff3b-f52f-4933-9879-1b47857d8c67",
|
|
"metadata": {
|
|
"jp-MarkdownHeadingCollapsed": true,
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"## 低碳院人员体质分组"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "b18747ae-bda7-40bb-af9d-76a987608b81",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 导出至Excel文件"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "a1473ba9-9d8b-4b8a-91a4-d72d680aed8b",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"import json\n",
|
|
"\n",
|
|
"dict1 = {}\n",
|
|
"fl_name = 'data/低碳院人员信息.json'\n",
|
|
"with open(fl_name,'r') as fl:\n",
|
|
" m_xx = json.load(fl)\n",
|
|
" \n",
|
|
"#print(m_xx)\n",
|
|
"fi_xls = 'data/适应A组.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,3).value is not None:\n",
|
|
" m_dm = str(sheet.cell(n,1).value)\n",
|
|
" m_name = sheet.cell(n,2).value\n",
|
|
" m_email = m_xx[m_dm][2]\n",
|
|
" m_pn = m_xx[m_dm][3]\n",
|
|
" dict1[m_dm.rjust(5,\"0\")] = [m_name,m_email,m_pn]\n",
|
|
"m_dm = []\n",
|
|
"for item in dict1.keys():\n",
|
|
" m_dm.append(item.rjust(5,\"0\"))\n",
|
|
"m_dm.sort()\n",
|
|
"wb = openpyxl.Workbook()\n",
|
|
"sheet = wb.active\n",
|
|
"i = 2\n",
|
|
"sheet[f'A1'] = '编号'\n",
|
|
"sheet[f'B1'] = '姓名'\n",
|
|
"sheet[f'C1'] = '邮箱'\n",
|
|
"sheet[f'D1'] = '电话'\n",
|
|
"for item in m_dm:\n",
|
|
" sheet[f'A{i}'] = item\n",
|
|
" sheet[f'B{i}'] = dict1[item][0]\n",
|
|
" sheet[f'C{i}'] = dict1[item][1]\n",
|
|
" sheet[f'D{i}'] = dict1[item][2]\n",
|
|
" i+=1\n",
|
|
"wb.save('data/A.xlsx') "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "1bb5122f-6100-44b4-9f65-9fac74f69136",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 导出邮件发送人信息"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "9635e141-60f7-4128-baed-d9c31c1fb1b1",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"import json\n",
|
|
"\n",
|
|
"dict1 = {}\n",
|
|
"fl_name = 'data/低碳院人员信息.json'\n",
|
|
"with open(fl_name,'r') as fl:\n",
|
|
" m_xx = json.load(fl)\n",
|
|
" \n",
|
|
"#print(m_xx)\n",
|
|
"list1 = []\n",
|
|
"fi_xls = 'data/适应A组.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,3).value is not None:\n",
|
|
" m_dm = str(sheet.cell(n,1).value)\n",
|
|
" m_name = sheet.cell(n,2).value\n",
|
|
" m_email = m_xx[m_dm][2]\n",
|
|
" m_pn = m_xx[m_dm][3]\n",
|
|
" dict1[m_dm.rjust(5,\"0\")] = [m_name,m_email,m_pn]\n",
|
|
"m_dm = []\n",
|
|
"for item in dict1.keys():\n",
|
|
" m_dm.append(item)\n",
|
|
"m_dm.sort()\n",
|
|
"for s in m_dm:\n",
|
|
" if dict1[s][1]:\n",
|
|
" list1.append(dict1[s][1])\n",
|
|
"#print(';'.join(list1))\n",
|
|
"m_len = len(list1)\n",
|
|
"if m_len > 200:\n",
|
|
" mail_list1 = []\n",
|
|
" mail_list2 = []\n",
|
|
" mail_list3 = []\n",
|
|
" for i in range(0,100):\n",
|
|
" mail_list1.append(list1[i])\n",
|
|
" for i in range(100,200):\n",
|
|
" mail_list2.append(list1[i])\n",
|
|
" for i in range(200,m_len):\n",
|
|
" mail_list3.append(list1[i])\n",
|
|
" #print(len(mail_list1),len(mail_list2))\n",
|
|
" print(';'.join(mail_list1))\n",
|
|
" print('\\n')\n",
|
|
" print(';'.join(mail_list2))\n",
|
|
" print('\\n')\n",
|
|
" print(';'.join(mail_list3))\n",
|
|
"else:\n",
|
|
" mail_list1 = []\n",
|
|
" for i in range(0,m_len):\n",
|
|
" mail_list1.append(list1[i])\n",
|
|
" print(';'.join(mail_list1))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "ce79e61f-83c4-4425-b27b-e9edf8fb20cd",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 汇总分组导出Excel"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "ad88fd2a-39ce-4a88-bd4a-7699264fd47d",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"import json\n",
|
|
"\n",
|
|
"dict1 = {}\n",
|
|
"fl_name = 'data/低碳院人员信息.json'\n",
|
|
"with open(fl_name,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
" \n",
|
|
"#print(m_xx)\n",
|
|
"list1 = ['适应A组','适应B组','适应C组','提高组']\n",
|
|
"for item in list1:\n",
|
|
" fi_xls = f'data/{item}.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,3).value is not None:\n",
|
|
" m_dm = str(sheet.cell(n,1).value) \n",
|
|
" dict1[m_dm].append(item)\n",
|
|
"wb = openpyxl.Workbook()\n",
|
|
"sheet = wb.active\n",
|
|
"sheet['A1'] = '编号'\n",
|
|
"sheet['B1'] = '姓名'\n",
|
|
"sheet['C1'] = '性别'\n",
|
|
"sheet['D1'] = '出生日期'\n",
|
|
"sheet['E1'] = '部门'\n",
|
|
"sheet['F1'] = '邮件'\n",
|
|
"sheet['G1'] = '联系电话'\n",
|
|
"sheet['H1'] = '组别'\n",
|
|
"i = 2 \n",
|
|
"for k, v in dict1.items(): \n",
|
|
" sheet[f'A{i}'] = k\n",
|
|
" sheet[f'B{i}'] = v[0]\n",
|
|
" sheet[f'C{i}'] = v[3]\n",
|
|
" sheet[f'D{i}'] = v[4]\n",
|
|
" sheet[f'E{i}'] = v[1]\n",
|
|
" sheet[f'F{i}'] = v[2]\n",
|
|
" sheet[f'G{i}'] = v[5]\n",
|
|
" sheet[f'H{i}'] = v[6]\n",
|
|
" i+= 1\n",
|
|
" \n",
|
|
"wb.save('data/低碳院人员运动分组表.xlsx') "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "231a0872-34ac-4121-870e-ba398a158576",
|
|
"metadata": {
|
|
"jp-MarkdownHeadingCollapsed": true,
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"## 合并人员成绩"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "968eacff-74c0-4a2f-aa2a-c29b6da71364",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"import math\n",
|
|
"import json\n",
|
|
"\n",
|
|
"dict1 = {}\n",
|
|
"\n",
|
|
" \n",
|
|
"#print(m_xx)\n",
|
|
"fi_xls = 'data/成绩得分4.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,1).value is not None:\n",
|
|
" m_dm = sheet.cell(n,1).value\n",
|
|
" list1 = []\n",
|
|
" for i in range(2,28):\n",
|
|
" list1.append(sheet.cell(n,i).value)\n",
|
|
" dict1[m_dm] = list1\n",
|
|
"fi_xls = 'data/成绩得分5.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,1).value is not None:\n",
|
|
" m_dm = sheet.cell(n,1).value\n",
|
|
" list1 = []\n",
|
|
" for i in range(2,28):\n",
|
|
" list1.append(sheet.cell(n,i).value)\n",
|
|
" dict1[m_dm] = list1\n",
|
|
"#print(dict1)\n",
|
|
"wb = openpyxl.Workbook()\n",
|
|
"sheet = wb.active\n",
|
|
"i = 1\n",
|
|
" \n",
|
|
"for k, v in dict1.items():\n",
|
|
" m_bh = str(k).rjust(5,\"0\")\n",
|
|
" list2=['B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA']\n",
|
|
" sheet[f'A{i}'] = k\n",
|
|
" for ii in range(0,26): \n",
|
|
" sheet[f'{list2[ii]}{i}'] = v[ii]\n",
|
|
" ii+= 1\n",
|
|
" i+= 1\n",
|
|
" \n",
|
|
"wb.save('data/合并.xlsx') \n",
|
|
" \n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "0bef4bd3-99e8-4a2d-a418-77f832b1254a",
|
|
"metadata": {
|
|
"jp-MarkdownHeadingCollapsed": true,
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"## 导出人员信息表"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "c0dac48c-490a-4632-8bdc-46c09adb9de8",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"import math\n",
|
|
"import json\n",
|
|
" \n",
|
|
"dict1 = {}\n",
|
|
"fl_name = 'data/低碳院人员信息.json'\n",
|
|
"with open(fl_name,'r') as fl:\n",
|
|
" m_xx = json.load(fl)\n",
|
|
" \n",
|
|
"wb = openpyxl.Workbook()\n",
|
|
"sheet = wb.active\n",
|
|
"sheet['A1'] = '编号'\n",
|
|
"sheet['B1'] = '姓名'\n",
|
|
"sheet['C1'] = '性别'\n",
|
|
"sheet['D1'] = '出生日期'\n",
|
|
"sheet['E1'] = '部门'\n",
|
|
"sheet['F1'] = '邮件'\n",
|
|
"sheet['G1'] = '联系电话'\n",
|
|
"i = 2 \n",
|
|
"for k, v in m_xx.items():\n",
|
|
" m_bh = str(k).rjust(5,\"0\")\n",
|
|
" sheet[f'A{i}'] = k\n",
|
|
" sheet[f'B{i}'] = v[0]\n",
|
|
" sheet[f'C{i}'] = v[3]\n",
|
|
" sheet[f'D{i}'] = v[4]\n",
|
|
" sheet[f'E{i}'] = v[1]\n",
|
|
" sheet[f'F{i}'] = v[2]\n",
|
|
" sheet[f'G{i}'] = v[5]\n",
|
|
" i+= 1\n",
|
|
" \n",
|
|
"wb.save('data/低碳院人员信息表.xlsx') "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "b1462a26-59f8-4e5f-8fb9-d927059e0747",
|
|
"metadata": {
|
|
"jp-MarkdownHeadingCollapsed": true,
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"## 获取第一次报告人员情况"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "a09d16d7-62a8-4628-9df3-4658a78a9a14",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
" \n",
|
|
"dict1 = {}\n",
|
|
"fl_name = 'data/低碳院报告.json'\n",
|
|
"with open(fl_name,'r') as fl:\n",
|
|
" m_xx = json.load(fl)\n",
|
|
"print(len(m_xx.keys()))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "bb3448ff-a8d3-417d-ab3a-4b54e28aaca0",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 2023年体测情况"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "d7ad01ef-93c3-4735-b609-bb5d38f85a25",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 导入最新人员手机信息"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "dfa3f093-25a7-4a8d-b4d6-22e0f6fcbb92",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"import math\n",
|
|
"import json\n",
|
|
"import pymysql\n",
|
|
"\n",
|
|
"fi_xls = 'data/低碳院多点账号20230217.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",
|
|
"\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",
|
|
" dict1[int(sheet.cell(n,1).value)] = [sheet.cell(n,2).value,sheet.cell(n,3).value,str(sheet.cell(n,4).value).strip()]\n",
|
|
"#print(dict1)\n",
|
|
"i = 1\n",
|
|
"for k, v in dict1.items():\n",
|
|
" if v[0] in dict2.keys() and v[2]!=dict2[v[0]][0]:\n",
|
|
" print(i,v[0],v[2],dict2[v[0]][1])\n",
|
|
" i+= 1"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "c27c6f4b-d0ed-40e8-aed9-09662edd21c6",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 统计问卷人员信息"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "8ccee97e-60e0-4363-b706-d4a71f214142",
|
|
"metadata": {
|
|
"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/低碳院多点账号20230217.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",
|
|
" list1.append(str(sheet.cell(n,4).value).strip())\n",
|
|
"#print(list1)\n",
|
|
"list2 = []\n",
|
|
"list3 = []\n",
|
|
"\n",
|
|
"\n",
|
|
"db = pymysql.connect(host = \"localhost\",user = \"songyi\",password = \"yylzs\",database = \"ydyb\" )\n",
|
|
"cursor = db.cursor()\n",
|
|
"sql = \"select * FROM Survey s WHERE s.surveyId IN ('psy6') 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[1]]\n",
|
|
" dict2[result[0]] = str(result[2]).strip()\n",
|
|
"#print(dict2)\n",
|
|
"for k, v in dict2.items():\n",
|
|
" if v not in list1:\n",
|
|
" list2.append(v)\n",
|
|
"sql = \"SELECT a.phone 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",
|
|
" list3.append(result[0])\n",
|
|
"#print(dict2)\n",
|
|
"for item in list2:\n",
|
|
" if item not in list3:\n",
|
|
" print(item)\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "9ba6ea9a-28f5-43c7-9dd7-74a626838303",
|
|
"metadata": {},
|
|
"source": [
|
|
"### 统计2022年问卷人员信息"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "1ddcc50e-f6b5-4fcc-8bb4-64ebb1d6f9e3",
|
|
"metadata": {},
|
|
"source": [
|
|
"#### 统计2022年问卷人员总信息"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "2339b885-e885-499a-a078-5a2a1fb818bd",
|
|
"metadata": {
|
|
"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/低碳院多点账号20230217.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",
|
|
" list1.append(str(sheet.cell(n,4).value).strip())\n",
|
|
"#print(list1)\n",
|
|
"list2 = []\n",
|
|
"list3 = []\n",
|
|
"\n",
|
|
"\n",
|
|
"db = pymysql.connect(host = \"localhost\",user = \"songyi\",password = \"yylzs\",database = \"ydyb\" )\n",
|
|
"cursor = db.cursor()\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[1]]\n",
|
|
" dict2[result[0]] = str(result[2]).strip()\n",
|
|
"#print(dict2)\n",
|
|
"for k, v in dict2.items():\n",
|
|
" if v not in list1:\n",
|
|
" list2.append(v)\n",
|
|
"sql = \"SELECT a.phone 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",
|
|
" list3.append(result[0])\n",
|
|
"#print(dict2)\n",
|
|
"for item in list2:\n",
|
|
" if item not in list3:\n",
|
|
" 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": "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": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.10.6"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|