20230426
This commit is contained in:
1 parent
60cd4d2643
commit
d5af3bcb91
6 files changed
+896
-218
No files matched your search
+210
-18
@@ -892,7 +892,7 @@
|
||||
" dict1['unit'] = sheet.cell(n, 1).value\n",
|
||||
" person[phone] = dict1\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/Survey_20230418-psy.csv'\n",
|
||||
"filename = 'data/Survey_20230424-tcm5.csv'\n",
|
||||
"with open(filename,'r',newline='') as csv_file:\n",
|
||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||
" header = next(fl) \n",
|
||||
@@ -906,7 +906,7 @@
|
||||
" if k not in cjry:\n",
|
||||
" list2.append([k,person[k]['name'],person[k]['unit']])\n",
|
||||
" \n",
|
||||
"filename = 'data/交警支队未参加中医评估人员(20230417).xlsx'\n",
|
||||
"filename = 'data/交警支队未参加中医评估人员(20230424).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"#sheet.append(title)\n",
|
||||
@@ -928,7 +928,9 @@
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d54bd635-c0d8-4527-811f-6d28f9cf68ae",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
@@ -940,6 +942,74 @@
|
||||
"person = {}\n",
|
||||
"cjry = set()\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" if sheet.cell(n,2).value is None:gangx\n",
|
||||
" break\n",
|
||||
" else: \n",
|
||||
" phone = sheet.cell(n, 5).value \n",
|
||||
" person.setdefault(phone, {})\n",
|
||||
" dict1 = {}\n",
|
||||
" dict1['name'] = sheet.cell(n, 2).value \n",
|
||||
" xb = str(sheet.cell(n, 3).value)\n",
|
||||
" if xb == '1':\n",
|
||||
" sex = '男'\n",
|
||||
" elif xb =='2':\n",
|
||||
" sex = '女'\n",
|
||||
" dict1['sex'] = sex\n",
|
||||
" dict1['unit'] = sheet.cell(n, 1).value\n",
|
||||
" person[phone] = dict1\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/Survey_20230424-jj.csv'\n",
|
||||
"with open(filename,'r',newline='') as csv_file:\n",
|
||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||
" header = next(fl) \n",
|
||||
" for line in fl:\n",
|
||||
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
||||
" cjry.add(line[2])\n",
|
||||
"print(len(cjry))\n",
|
||||
"\n",
|
||||
"list2 = []\n",
|
||||
"for item in cjry: \n",
|
||||
" if str(item) not in person.keys():\n",
|
||||
" list2.append(['','',item])\n",
|
||||
"filename = 'data/交警支队缺失信息人员(20230424).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"#sheet.append(title)\n",
|
||||
"for row in list2:\n",
|
||||
" sheet.append(row)\n",
|
||||
" \n",
|
||||
"wb.save(filename)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "c0f7a72a-3930-4c05-bf96-e65f0f83a634",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 统计生成报告人员情况表"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "a9a871ae-ab54-4f49-ada4-438b6a3e10be",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
"import glob,os,shutil\n",
|
||||
"from pathlib2 import Path\n",
|
||||
"import csv\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/淄博交警支队人员名单(排序花名册).xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"person = {}\n",
|
||||
"depart = []\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" if sheet.cell(n,2).value is None:\n",
|
||||
" break\n",
|
||||
" else: \n",
|
||||
@@ -956,24 +1026,146 @@
|
||||
" dict1['unit'] = sheet.cell(n, 1).value\n",
|
||||
" person[phone] = dict1\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/Survey_20230418-psy.csv'\n",
|
||||
"with open(filename,'r',newline='') as csv_file:\n",
|
||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||
" header = next(fl) \n",
|
||||
" for line in fl:\n",
|
||||
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
||||
" cjry.add(line[2])\n",
|
||||
"print(len(cjry))\n",
|
||||
"list2 = []\n",
|
||||
"for item in cjry:\n",
|
||||
" if str(item) not in person.keys():\n",
|
||||
" print(item)\n"
|
||||
"dict1 = {}\n",
|
||||
"old = []\n",
|
||||
"fi_path = 'file/132/20230425'\n",
|
||||
"fl=glob.glob(f'{fi_path}/*.pdf')\n",
|
||||
"print(len(fl))\n",
|
||||
"for fn in fl:\n",
|
||||
" phone = Path(fn).stem\n",
|
||||
" if phone in person.keys():\n",
|
||||
" name = person[phone]['name']\n",
|
||||
" unit = person[phone]['unit']\n",
|
||||
" else:\n",
|
||||
" name = ''\n",
|
||||
" unit ='未明确部门'\n",
|
||||
" if unit not in depart:\n",
|
||||
" depart.append(unit)\n",
|
||||
" dict1[phone] = {'name':name,'unit':unit}\n",
|
||||
"print(depart)\n",
|
||||
"m_path = 'file/132/new'\n",
|
||||
"for pn in depart:\n",
|
||||
" if not os.path.exists(m_path + '/' + pn):\n",
|
||||
" os.mkdir(m_path + '/' + pn)\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",
|
||||
" unit = dict1[str(n)]['unit']\n",
|
||||
" \n",
|
||||
" n_name = f'{m_path}/{unit}/{str(n)}.pdf'\n",
|
||||
" #print(o_name,n_name)\n",
|
||||
" if not os.path.exists(n_name):\n",
|
||||
" shutil.copyfile(o_name,n_name)\n",
|
||||
" print(n_name)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 44,
|
||||
"id": "790407ea-3461-4533-8775-390ea3465da9",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-04-25T12:17:16.457023Z",
|
||||
"iopub.status.busy": "2023-04-25T12:17:16.456189Z",
|
||||
"iopub.status.idle": "2023-04-25T12:17:16.698120Z",
|
||||
"shell.execute_reply": "2023-04-25T12:17:16.697394Z",
|
||||
"shell.execute_reply.started": "2023-04-25T12:17:16.456992Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"452\n",
|
||||
"['博山大队', '桓台大队', '未明确部门', '支队', '淄川大队', '文昌湖大队', '支队车管所', '高青大队', '张店大队', '设施大队', '周村大队', '高新区大队', '支队外调人员', '沂源大队', '退休人员', '临淄大队']\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
"import glob,os,shutil\n",
|
||||
"from pathlib2 import Path\n",
|
||||
"import csv\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/淄博交警支队人员名单(排序花名册).xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"person = {}\n",
|
||||
"depart = []\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" if sheet.cell(n,2).value is None:\n",
|
||||
" break\n",
|
||||
" else: \n",
|
||||
" phone = sheet.cell(n, 5).value \n",
|
||||
" person.setdefault(phone, {})\n",
|
||||
" dict1 = {}\n",
|
||||
" dict1['name'] = sheet.cell(n, 2).value \n",
|
||||
" xb = str(sheet.cell(n, 3).value)\n",
|
||||
" if xb == '1':\n",
|
||||
" sex = '男'\n",
|
||||
" elif xb =='2':\n",
|
||||
" sex = '女'\n",
|
||||
" dict1['sex'] = sex\n",
|
||||
" dict1['unit'] = sheet.cell(n, 1).value\n",
|
||||
" person[phone] = dict1\n",
|
||||
"list1 = []\n",
|
||||
"dict1 = {}\n",
|
||||
"old = []\n",
|
||||
"fi_path = 'file/132/20230425'\n",
|
||||
"fl=glob.glob(f'{fi_path}/*.pdf')\n",
|
||||
"print(len(fl))\n",
|
||||
"for fn in fl:\n",
|
||||
" phone = Path(fn).stem\n",
|
||||
" if phone in person.keys():\n",
|
||||
" name = person[phone]['name']\n",
|
||||
" unit = person[phone]['unit']\n",
|
||||
" else:\n",
|
||||
" name = ''\n",
|
||||
" unit ='未明确部门'\n",
|
||||
" if unit not in depart:\n",
|
||||
" depart.append(unit)\n",
|
||||
" dict1[phone] = {'name':name,'unit':unit}\n",
|
||||
"print(depart)\n",
|
||||
"m_path = 'file/132/new'\n",
|
||||
"for pn in depart:\n",
|
||||
" if not os.path.exists(m_path + '/' + pn):\n",
|
||||
" os.mkdir(m_path + '/' + pn)\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",
|
||||
" unit = dict1[str(n)]['unit'] \n",
|
||||
" n_name = f'{m_path}/{unit}/{str(n)}.pdf'\n",
|
||||
" list1.append([unit,n])\n",
|
||||
"filename = 'data/淄博交警报告打印明细表.xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"title = ['部门','手机号码']\n",
|
||||
"sheet.append(title)\n",
|
||||
"for row in list1:\n",
|
||||
" sheet.append(row)\n",
|
||||
" \n",
|
||||
"wb.save(filename)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "908df4fc-254f-4525-a199-e0b82469af81",
|
||||
"id": "c26f4d44-d58d-4a37-a117-ac4a90a67866",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
@@ -981,7 +1173,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -995,7 +1187,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.10"
|
||||
"version": "3.10.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in new issue
Block a user