This commit is contained in:
512song committed 2021-12-21 23:00:39 +08:00
1 parent 5e79ead37f
commit 89a3cfb257
2 files changed
+68 -2

No files matched your search

+66
View File
@@ -787,6 +787,72 @@
"#print(type(x))"
]
},
{
"cell_type": "markdown",
"id": "4d255389-bc5c-4251-861e-3a4d65bf5c26",
"metadata": {},
"source": [
"## 根据体测报告生成分组表"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "ed6b40e9-4c5f-4d1f-8810-9f519a8755b0",
"metadata": {
"execution": {
"iopub.execute_input": "2021-12-21T14:57:58.154705Z",
"iopub.status.busy": "2021-12-21T14:57:58.153424Z",
"iopub.status.idle": "2021-12-21T14:57:59.771235Z",
"shell.execute_reply": "2021-12-21T14:57:59.767942Z",
"shell.execute_reply.started": "2021-12-21T14:57:58.154596Z"
},
"tags": []
},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"import os,sys,shutil\n",
"import glob\n",
"\n",
"fl=glob.glob('./file/211130/*.pdf')\n",
"list1 = []\n",
"for fi in fl:\n",
" s = os.path.basename(fi).split('.')[0]\n",
" list1.append(int(s))\n",
"list1.sort()\n",
"#print(list1)\n",
"wb = openpyxl.load_workbook('data/济南炼化.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"depart = []\n",
"dict1 = {}\n",
"new_code = []\n",
"for n in range(2, sheet.max_row+1):\n",
" m_depart = sheet.cell(n,5).value\n",
" dict2 = {}\n",
" dict1.setdefault(m_depart,[])\n",
" dict2[sheet.cell(n,1).value] = sheet.cell(n,2).value\n",
" dict1[m_depart].append(dict2)\n",
"wb = openpyxl.Workbook()\n",
"\n",
"sheet = wb.active\n",
"i = 1\n",
"\n",
"for k , v in dict1.items():\n",
" sheet[f'A{i}'] = k\n",
" i += 1\n",
" for item in v:\n",
" for k1, v1 in item.items():\n",
" if k1 in list1:\n",
" sheet[f'A{i}'] = str(k1).rjust(5,\"0\")\n",
" sheet[f'B{i}'] = v1\n",
" i += 1\n",
"wb.save('./data/济南炼化体测报告部门明细表.xlsx')\n",
"#print(dict1)\n"
]
},
{
"cell_type": "markdown",
"id": "c67fc14e-ccf8-41c5-a0f8-0c3a664eb484",