694 lines
20 KiB
Plaintext
694 lines
20 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": 4,
|
|
"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"
|
|
]
|
|
}
|
|
],
|
|
"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": 8,
|
|
"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"
|
|
]
|
|
}
|
|
],
|
|
"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": "code",
|
|
"execution_count": 11,
|
|
"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"
|
|
]
|
|
}
|
|
],
|
|
"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": "code",
|
|
"execution_count": null,
|
|
"id": "30704310-351a-406d-a0fe-02a5cefe6012",
|
|
"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
|
|
}
|