This commit is contained in:
512song committed 2023-05-06 21:32:55 +08:00
1 parent 89ae72f87e
commit 3c8e9c5157
8 files changed
+728 -191

No files matched your search

+208 -1
View File
@@ -1162,10 +1162,217 @@
"wb.save(filename)"
]
},
{
"cell_type": "markdown",
"id": "b0f8f072-c8d2-4259-8785-4f2a37a06b66",
"metadata": {},
"source": [
"### 生成参加评测人员信息"
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "ec6779c9-4cf2-4fb9-b6ce-430eeca07046",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-05T00:42:59.292182Z",
"iopub.status.busy": "2023-05-05T00:42:59.291341Z",
"iopub.status.idle": "2023-05-05T00:42:59.515203Z",
"shell.execute_reply": "2023-05-05T00:42:59.514466Z",
"shell.execute_reply.started": "2023-05-05T00:42:59.292142Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"452\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",
" sex = person[phone]['sex']\n",
" else:\n",
" name = ''\n",
" unit ='未明确部门'\n",
" sex = ''\n",
" if unit not in depart:\n",
" depart.append(unit)\n",
" dict1[phone] = {'name':name,'unit':unit,'sex':sex}\n",
"filename = 'data/淄博交警参加测评人员.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl,ensure_ascii=False) "
]
},
{
"cell_type": "markdown",
"id": "f9686f85-2d33-4e4d-8d4d-498237c26d2c",
"metadata": {},
"source": [
"### 生成心理测评人员明细"
]
},
{
"cell_type": "code",
"execution_count": 52,
"id": "b915259c-755b-4d8a-98f0-ef8707624b38",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-05T00:43:56.396524Z",
"iopub.status.busy": "2023-05-05T00:43:56.395990Z",
"iopub.status.idle": "2023-05-05T00:43:56.874426Z",
"shell.execute_reply": "2023-05-05T00:43:56.873679Z",
"shell.execute_reply.started": "2023-05-05T00:43:56.396492Z"
},
"tags": []
},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"import csv\n",
"filename = 'data/淄博交警参加测评人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"cjry = set()\n",
"filename = 'data/Survey_20230424-psy3.csv'\n",
"list2 = []\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",
" phone = str(line[2])\n",
" result = json.loads(line[5]) \n",
" \n",
" if phone in dict1.keys():\n",
" list1 = []\n",
" \n",
" list1.append(phone)\n",
" list1.append(dict1[phone]['name'])\n",
" list1.append(dict1[phone]['sex'])\n",
" list1.append(dict1[phone]['unit'])\n",
" #print(k,v['phone'],type(result))\n",
" for k1, v1 in result.items():\n",
" list1.append(v1)\n",
" list2.append(list1)\n",
"filename = 'data/交警心理评估明细表.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)"
]
},
{
"cell_type": "markdown",
"id": "b19438f4-1fbe-480f-9809-3db7af008812",
"metadata": {},
"source": [
"### 生成中医测评人员明细"
]
},
{
"cell_type": "code",
"execution_count": 53,
"id": "596b26a5-42cc-400f-8c6f-39bfa0fb9233",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-05T00:46:28.321827Z",
"iopub.status.busy": "2023-05-05T00:46:28.321422Z",
"iopub.status.idle": "2023-05-05T00:46:28.612694Z",
"shell.execute_reply": "2023-05-05T00:46:28.612003Z",
"shell.execute_reply.started": "2023-05-05T00:46:28.321799Z"
},
"tags": []
},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"import csv\n",
"filename = 'data/淄博交警参加测评人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"cjry = set()\n",
"filename = 'data/Survey_20230424-tcm5.csv'\n",
"list2 = []\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",
" phone = str(line[2])\n",
" result = json.loads(line[5]) \n",
" \n",
" if phone in dict1.keys():\n",
" list1 = []\n",
" \n",
" list1.append(phone)\n",
" list1.append(dict1[phone]['name'])\n",
" list1.append(dict1[phone]['sex'])\n",
" list1.append(dict1[phone]['unit'])\n",
" #print(k,v['phone'],type(result))\n",
" for k1, v1 in result.items():\n",
" list1.append(v1)\n",
" list2.append(list1)\n",
"filename = 'data/交警中医评估明细表.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)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c26f4d44-d58d-4a37-a117-ac4a90a67866",
"id": "eac36b4d-943b-4d1f-9d64-f1c63daf7b40",
"metadata": {},
"outputs": [],
"source": []