This commit is contained in:
512song@sina.com committed 2022-10-15 22:44:29 +08:00
1 parent fc3ae448ca
commit 02a878a739
2 files changed
+558

No files matched your search

+468
View File
@@ -0,0 +1,468 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "4b749231-7ab9-4dcd-8cfd-7b9be485d3c6",
"metadata": {},
"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": {},
"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": 85,
"id": "ad88fd2a-39ce-4a88-bd4a-7699264fd47d",
"metadata": {
"execution": {
"iopub.execute_input": "2022-08-02T00:02:15.159762Z",
"iopub.status.busy": "2022-08-02T00:02:15.159231Z",
"iopub.status.idle": "2022-08-02T00:02:15.980533Z",
"shell.execute_reply": "2022-08-02T00:02:15.979419Z",
"shell.execute_reply.started": "2022-08-02T00:02:15.159712Z"
},
"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": {},
"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": {},
"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": {},
"source": [
"## 获取第一次报告人员情况"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "a09d16d7-62a8-4628-9df3-4658a78a9a14",
"metadata": {
"execution": {
"iopub.execute_input": "2022-08-09T01:55:02.666968Z",
"iopub.status.busy": "2022-08-09T01:55:02.666453Z",
"iopub.status.idle": "2022-08-09T01:55:02.676595Z",
"shell.execute_reply": "2022-08-09T01:55:02.675414Z",
"shell.execute_reply.started": "2022-08-09T01:55:02.666920Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"332\n"
]
}
],
"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": "code",
"execution_count": null,
"id": "199c011d-a253-429a-ad51-645b37f679a1",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
+90
View File
@@ -0,0 +1,90 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "ae533fe9-e20e-4e44-b9bb-030c4fa4e714",
"metadata": {},
"source": [
"## 体测人员导入"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "1144aaac-92a0-4bcf-aba7-096f7dd3ad3b",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-15T14:33:57.992886Z",
"iopub.status.busy": "2022-10-15T14:33:57.992353Z",
"iopub.status.idle": "2022-10-15T14:33:59.266279Z",
"shell.execute_reply": "2022-10-15T14:33:59.265333Z",
"shell.execute_reply.started": "2022-10-15T14:33:57.992838Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/天津石化员工检测花名册 (20221014).xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"\n",
"for n in range(2, sheet.max_row+1):\n",
" code = sheet.cell(n, 6).value\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 3).value\n",
" dict1['sex'] = sheet.cell(n, 4).value\n",
" dict1['unit'] = sheet.cell(n, 1).value\n",
" dict1['sub_unit'] = sheet.cell(n, 2).value\n",
" dict1['id_num'] = sheet.cell(n,5).value\n",
" person[code] = dict1\n",
"filename = 'data/天津石化人员名单.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print('ok')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bf980970-b95f-47f3-a93d-55a659f52471",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}