20220728
This commit is contained in:
1 parent
fdf955d282
commit
34c948fb58
2 files changed
+336
-60
No files matched your search
+205
-8
@@ -64,6 +64,210 @@
|
||||
"#print(dict1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "72866db8-89be-4498-b854-a3aefe4c897a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 低碳院人员信息转换"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "433c3f52-f4ae-4544-8d06-3636feae71ba",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os,sys,shutil\n",
|
||||
"import openpyxl\n",
|
||||
"import math\n",
|
||||
"\n",
|
||||
"fi_xls = os.getcwd() + '/data/北京低碳监测.xlsx'\n",
|
||||
"fi_path = os.getcwd() + '/file/220724'\n",
|
||||
"old = []\n",
|
||||
"dict1 = {}\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook(fi_xls)\n",
|
||||
"sheet = wb.active\n",
|
||||
"depart = []\n",
|
||||
"for n in range(2,sheet.max_row): \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",
|
||||
"\n",
|
||||
"m_path = os.getcwd()+'/file/220724/new'\n",
|
||||
"\n",
|
||||
"fl=os.listdir(fi_path)\n",
|
||||
"for fn in fl:\n",
|
||||
" if os.path.isfile(fi_path + '/' + fn):\n",
|
||||
" ofn = int(fn.split('.')[0])\n",
|
||||
" old.append(ofn) \n",
|
||||
"old.sort()\n",
|
||||
"for n in old: \n",
|
||||
" o_name = f'{fi_path}/{n}.pdf'\n",
|
||||
" n_name = f'{fi_path}/new/{str(n).rjust(5,\"0\")}-{dict1[n][0]}.pdf'\n",
|
||||
" if not os.path.exists(n_name):\n",
|
||||
" shutil.copyfile(o_name,n_name)\n",
|
||||
" print(n_name)\n",
|
||||
"#print(dict1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "cda8fbed-c0f2-4bfc-a23f-6b412bbcd0ba",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 低碳院人员信息核验"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "a34c9f6b-4ef3-4678-89bb-8b692e183968",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os,sys,shutil\n",
|
||||
"import openpyxl\n",
|
||||
"import math\n",
|
||||
"import json\n",
|
||||
"\n",
|
||||
"fi_xls = os.getcwd() + '/data/北京低碳监测.xlsx'\n",
|
||||
"fi_path = os.getcwd() + '/file/220724'\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",
|
||||
"\n",
|
||||
"fi_xls = os.getcwd() + '/data/1658883945637.xlsx'\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",
|
||||
" if sheet.cell(n,3).value is not None:\n",
|
||||
" dict2[sheet.cell(n,3).value] = [m_name,m_depart,m_dm]\n",
|
||||
"#print(dict2)\n",
|
||||
"fl=os.listdir(fi_path)\n",
|
||||
"for fn in fl:\n",
|
||||
" if os.path.isfile(fi_path + '/' + fn):\n",
|
||||
" ofn = int(fn.split('.')[0])\n",
|
||||
" old.append(ofn) \n",
|
||||
"old.sort()\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[n] = [m_name,m_depart,item[2]]\n",
|
||||
" break\n",
|
||||
"for k in old:\n",
|
||||
" if k not in dict3.keys():\n",
|
||||
" print(k)\n",
|
||||
"with open('data/低碳院报告.json','w') as fl2:\n",
|
||||
" json.dump(dict3,fl2,ensure_ascii=False) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3244663e-890c-48de-ae6a-1f666cb1bb76",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 低碳院人员附件核验"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "8e20ead8-754a-4535-95ea-b103264e3783",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"fl_name = 'data/低碳院报告.json'\n",
|
||||
"\n",
|
||||
"with open(fl_name,'r') as fl:\n",
|
||||
" m_xx = json.load(fl)\n",
|
||||
"for k, v in m_xx.items():\n",
|
||||
" m_bh = str(k).rjust(5,\"0\")\n",
|
||||
" fl_name = f'file/220724/new/{m_bh}-{v[0]}.pdf'\n",
|
||||
" if os.path.exists(fl_name):\n",
|
||||
" print(fl_name)\n",
|
||||
" else:\n",
|
||||
" print(f'{v[0]}不存在')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a7976e2e-23fa-4464-89f5-0e96f721bc95",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 低碳院人员导出"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 37,
|
||||
"id": "d77c3ff5-91fb-4449-80fb-57bc467c27bd",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2022-07-27T14:01:56.902136Z",
|
||||
"iopub.status.busy": "2022-07-27T14:01:56.901602Z",
|
||||
"iopub.status.idle": "2022-07-27T14:01:56.957533Z",
|
||||
"shell.execute_reply": "2022-07-27T14:01:56.956472Z",
|
||||
"shell.execute_reply.started": "2022-07-27T14:01:56.902088Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"fl_name = 'data/低碳院报告.json'\n",
|
||||
"\n",
|
||||
"with open(fl_name,'r') as fl:\n",
|
||||
" m_xx = json.load(fl)\n",
|
||||
" \n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"i = 0\n",
|
||||
" \n",
|
||||
"for k, v in m_xx.items():\n",
|
||||
" m_bh = str(k).rjust(5,\"0\")\n",
|
||||
" m_name = v[0]\n",
|
||||
" fl = f'{m_bh}-{v[0]}.pdf'\n",
|
||||
" m_rec = v[2]+'@ceic.com'\n",
|
||||
" i += 1\n",
|
||||
" sheet[f'A{i}'] = i\n",
|
||||
" sheet[f'B{i}'] = m_bh\n",
|
||||
" sheet[f'C{i}'] = m_name\n",
|
||||
" sheet[f'D{i}'] = m_rec \n",
|
||||
" sheet[f'E{i}'] = fl\n",
|
||||
" \n",
|
||||
"wb.save('data/低碳院邮件.xlsx') \n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "bbf0b425-c0ce-4608-ae52-85a78ddcd6c0",
|
||||
@@ -74,16 +278,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": null,
|
||||
"id": "2c2bd1d1-4d84-4639-ba20-c97c218ae275",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2022-05-06T14:01:25.901198Z",
|
||||
"iopub.status.busy": "2022-05-06T14:01:25.900687Z",
|
||||
"iopub.status.idle": "2022-05-06T14:01:25.911729Z",
|
||||
"shell.execute_reply": "2022-05-06T14:01:25.910606Z",
|
||||
"shell.execute_reply.started": "2022-05-06T14:01:25.901153Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
|
||||
Reference in new issue
Block a user