Files
jupyter/体测单位/淄博交警支队.ipynb
T
2022-10-18 19:03:07 +08:00

1013 lines
33 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "9aa09f7b-6a13-471b-91ed-c56d1ccc4d2c",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-10T02:37:38.847757Z",
"iopub.status.busy": "2022-10-10T02:37:38.847228Z",
"iopub.status.idle": "2022-10-10T02:37:38.853747Z",
"shell.execute_reply": "2022-10-10T02:37:38.852087Z",
"shell.execute_reply.started": "2022-10-10T02:37:38.847708Z"
},
"tags": []
},
"source": [
"## 人员信息导入"
]
},
{
"cell_type": "markdown",
"id": "53b09d89-0cd6-4d84-b493-d47918664201",
"metadata": {},
"source": [
"### 人员基本信息导入"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ce9b96fd-4bc1-4fd3-8339-5992a86c7001",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"wb = openpyxl.load_workbook('data/交警支队最新名册.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"for n in range(2, sheet.max_row+1):\n",
" if sheet.cell(n,2).value is None:\n",
" break\n",
" else:\n",
" \n",
" code = int(sheet.cell(n, 4).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 6).value \n",
" xb = str(sheet.cell(n, 7).value)\n",
" if xb == '1':\n",
" sex = '男'\n",
" elif xb =='2':\n",
" sex = '女'\n",
" dict1['sex'] = sex\n",
" dict1['unit'] = sheet.cell(n, 3).value\n",
" dict1['birth'] = str(sheet.cell(n,8).value).split(' ')[0]\n",
" person[code] = dict1\n",
"filename = 'data/交警支队名单221010.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "f684616c-98f2-4f37-81c8-77ab5a7389fa",
"metadata": {},
"source": [
"### 小鹅通人员信息导入"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e610a572-8699-4f35-a3db-de4c0b971686",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import os\n",
"import glob\n",
"import csv\n",
"\n",
"fi_path = 'data/小鹅通/'\n",
"dict1 = {}\n",
"fl = glob.glob(f'{fi_path}*.csv')\n",
"list1 = []\n",
"for fn in fl:\n",
" with open(fn,'r',newline='',encoding='gb18030') as csv_file:\n",
" fl1 = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl1) \n",
" for line in fl1:\n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" list1.append(line)\n",
"for item in list1:\n",
" dict1.setdefault(item[0],{})\n",
" dict1[item[0]]['nick'] = item[1]\n",
" dict1[item[0]]['name'] = item[4] \n",
" dict1[item[0]]['phone'] = item[5] \n",
"filename = 'data/小鹅通人员信息221010.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl,ensure_ascii=False) "
]
},
{
"cell_type": "markdown",
"id": "fa233427-c1ea-4005-a2bd-b2b9e94604d0",
"metadata": {},
"source": [
"### 人员手机号码导入"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2fd5b96c-0bbd-4a8f-8d72-002445101c92",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"wb = openpyxl.load_workbook('data/新部门排序-淄博交警支队人员名单 _56473.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\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",
" dict1['birth'] = str(sheet.cell(n,4).value).split(' ')[0]\n",
" person[phone] = dict1\n",
"filename = 'data/交警支队手机号码221010.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "c61f18ab-7411-44d4-9741-3dd50283f4bb",
"metadata": {},
"source": [
"### 关联人员手机号码及测试编号"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "73895efd-0d5e-4872-aca9-a697c3a0e774",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"\n",
"filename = 'data/交警支队名单221010.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"list2 = []\n",
"filename = 'data/交警支队手机号码221010.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"for k, v in dict2.items(): \n",
" list1 = [k,v['name'],v['birth'],v['unit']]\n",
" list2.append(list1)\n",
"for k, v in dict1.items():\n",
" name = v['name']\n",
" birth = v['birth']\n",
" for item in list2:\n",
" if name in item and birth in item:\n",
" dict1[k]['phone'] = item[0]\n",
" dict1[k]['unit'] = item[3]\n",
" dict2[item[0]]['code'] = k\n",
" break\n",
"filename = 'data/交警支队名单221010.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n",
"filename = 'data/交警支队手机号码221010.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(dict2, fl, ensure_ascii=False)\n",
"print('ok') \n",
" \n"
]
},
{
"cell_type": "markdown",
"id": "234d9b71-f99e-48cb-af9b-151bbf3f1715",
"metadata": {},
"source": [
"### 小鹅通人员分组(按照手机号关联)"
]
},
{
"cell_type": "code",
"execution_count": 76,
"id": "9aaa35a7-13e2-4ece-a9fd-931ad00e89d3",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-18T09:22:24.792753Z",
"iopub.status.busy": "2022-10-18T09:22:24.792240Z",
"iopub.status.idle": "2022-10-18T09:22:24.824328Z",
"shell.execute_reply": "2022-10-18T09:22:24.823342Z",
"shell.execute_reply.started": "2022-10-18T09:22:24.792705Z"
},
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"\n",
"filename = 'data/交警支队小鹅通信息221018.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"\n",
"filename = 'data/交警支队分组情况.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",
" phone = line[9]\n",
" group = line[1]\n",
" \n",
" if phone in dict1.keys():\n",
" \n",
" dict1[phone]['group'] = group\n",
"\n",
"filename = 'data/交警支队小鹅通信息221018.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl,ensure_ascii=False) "
]
},
{
"cell_type": "markdown",
"id": "e3a23383-e918-41c7-818e-6914ebfe7baf",
"metadata": {},
"source": [
"### 小鹅通人员信息关联"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fc1da208-192e-4b06-b42f-72e7d44245ad",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"filename = 'data/交警支队名单221010.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"dict2 = {}\n",
"for k, v in dict1.items():\n",
" if 'phone' in v.keys():\n",
" dict2.setdefault(v['phone'], {})\n",
" dict2[v['phone']]['name'] = v['name']\n",
" dict2[v['phone']]['sex'] = v['sex']\n",
" dict2[v['phone']]['unit'] = v['unit']\n",
" dict2[v['phone']]['birth'] = v['birth']\n",
"#print(dict2) \n",
"list1 = dict2.keys()\n",
"filename = 'data/小鹅通人员信息221010.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"for k, v in dict1.items():\n",
" phone = v['phone']\n",
" if phone in list1:\n",
" dict2[phone]['nick'] = v['nick']\n",
" dict2[phone]['user'] = v['name']\n",
" dict2[phone]['id'] = k\n",
"filename = 'data/交警支队小鹅通信息221010.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(dict2, fl, ensure_ascii=False)\n",
"print('ok') "
]
},
{
"cell_type": "markdown",
"id": "8136ea7b-d485-452d-b032-0cfa538166a9",
"metadata": {},
"source": [
"### 修正人员信息"
]
},
{
"cell_type": "code",
"execution_count": 74,
"id": "5678472e-b131-4940-9161-240dcd3461bb",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-18T09:18:04.991734Z",
"iopub.status.busy": "2022-10-18T09:18:04.991171Z",
"iopub.status.idle": "2022-10-18T09:18:05.041377Z",
"shell.execute_reply": "2022-10-18T09:18:05.040521Z",
"shell.execute_reply.started": "2022-10-18T09:18:04.991685Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"u_6300b7d4bc5a0_ayO3NftEDA 手机尾号3202用户 None 18705333202\n",
"u_lp_1663327661_63245dad5f702_I8JfuY 任振华 None 18705336366\n",
"u_6300b888d3aac_O39r6KCeML 王勇威 王勇威 18705336122\n",
"u_6300b8a21e3fe_zWo6UFSjrS 宗力 宗力 18705336363\n",
"u_lp_1663138566_63217b06daf80_S7mJ25 薛林 薛林 18705333903\n",
"u_lp_1664546227_6336f5b346d80_TiNiu1 房思春 房思春 18705333715\n",
"u_lp_1664617172_63380ad429dcb_svfFT3 海涛 祝学迎 18705336376\n",
"u_lp_1665641415_6347abc77a7ef_yV6Wox 董凯 董凯 15269362037\n",
"u_lp_1663406890_6325932a5caff_2RIkq2 祁河成 祁河成 18705333738\n",
"u_6325217365e69_WctQcZFuHb 张红海 张红海 18705333887\n",
"u_lp_1662620239_6319924fdf4a4_pB11t3 刘军 None 18705336318\n",
"u_lp_1661481758_6308331eaba3a_TQ1j6B 交警 翟峰 交警 翟峰 18705336675\n",
"u_lp_1663329993_632466c92bc76_uSmR9Q 孔晓晖 None 18705336315\n",
"u_lp_1663634037_63290a75694c9_cbt0Ld 王维军 快乐先行 18705336077\n",
"u_lp_1663649808_63294810ce3fd_UEPrNX 刘浩 刘浩 18705333203\n",
"u_lp_1663722388_632a6394b6954_7SupvO 李传生 李传生 18705336807\n",
"u_lp_1661486861_6308470de5d47_QzgTmI 张俊杰 张俊杰 18705336069\n",
"u_lp_1664162704_63311b90e964c_jPlmpl 童保华 None 18705333707\n",
"u_lp_1665036891_633e725b684d3_hsCm37 刘进 None 18705336031\n",
"u_lp_1663295972_6323e1e4caea7_fc1HXu 于会萍 None 18705333513\n",
"u_lp_1663325439_632454ff8b99b_DrUT6S 孙孝伟 None 18705336682\n",
"u_lp_1663577491_63282d93ea1e9_JDfOU8 王青海 王青海 18705336039\n",
"u_lp_1663663112_63297c08977aa_7gPZEP 车西冬 None 18705333710\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"filename = 'data/交警支队小鹅通信息221018.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"\n",
"wb = openpyxl.load_workbook('data/新增人员表221018.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"\n",
"for n in range(2, sheet.max_row+1):\n",
" if sheet.cell(n,1).value is None:\n",
" break\n",
" else:\n",
" phone = sheet.cell(n, 5).value\n",
" if phone in dict2.keys():\n",
" dict2[phone]['id'] = sheet.cell(n, 1).value\n",
" dict2[phone]['nick'] = sheet.cell(n, 3).value\n",
" dict2[phone]['user'] = sheet.cell(n, 2).value\n",
" print(sheet.cell(n, 1).value,sheet.cell(n, 3).value,sheet.cell(n, 2).value,phone)\n",
"\n",
"#with open(filename, 'w') as fl:\n",
"# json.dump(dict2, fl, ensure_ascii=False)\n",
"#print('ok')"
]
},
{
"cell_type": "markdown",
"id": "dc856c16-3ff0-4c24-a5ee-062129698e08",
"metadata": {},
"source": [
"## 打卡信息导入"
]
},
{
"cell_type": "code",
"execution_count": 77,
"id": "c1a5aaef-70be-4fd2-9384-983aeb59f491",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-18T09:22:39.019143Z",
"iopub.status.busy": "2022-10-18T09:22:39.018621Z",
"iopub.status.idle": "2022-10-18T09:22:39.175590Z",
"shell.execute_reply": "2022-10-18T09:22:39.174572Z",
"shell.execute_reply.started": "2022-10-18T09:22:39.019095Z"
},
"tags": []
},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"import os\n",
"import glob\n",
"import csv\n",
"import re\n",
"\n",
"filename = 'data/交警支队小鹅通信息221018.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"dict2 = {}\n",
"for k, v in dict1.items():\n",
" if 'id' in v.keys():\n",
" dict2[v['id']] = [v['name'],v['unit'],k,v['nick'],v['group']] \n",
"dict3 = {} \n",
"fi_path = 'data/交警支队/打卡/'\n",
"fl = glob.glob(f'{fi_path}*.csv')\n",
"list1 = []\n",
"for fn in fl:\n",
" with open(fn,'r',newline='') as csv_file:\n",
" fl1 = csv.reader(csv_file,delimiter=',')\n",
" group = re.findall(r'百日筑基-(.+)》',fn)[0]\n",
" header = next(fl1)\n",
" for line in fl1: \n",
" id = line[0]\n",
" num = line[10]\n",
" #print(id,num)\n",
" if id in dict2.keys() and dict2[id][4] == group:\n",
" dict3.setdefault(id,{})\n",
" dict3[id]['name'] = dict2[id][0]\n",
" dict3[id]['phone'] = dict2[id][2]\n",
" dict3[id]['unit'] = dict2[id][1]\n",
" dict3[id]['nick'] = dict2[id][3]\n",
" dict3[id]['dk'] = num\n",
"\n",
"fi_path = 'data/交警支队/时长/'\n",
"fl = glob.glob(f'{fi_path}*.csv')\n",
"\n",
"list1 = []\n",
"for fn in fl:\n",
" with open(fn,'r',newline='',encoding='gb18030') as csv_file:\n",
" fl1 = csv.reader(csv_file,delimiter=',')\n",
" group = re.findall(r'《(.+)》',fn)[0]\n",
" #header = next(fl1)\n",
" i = 0\n",
" for line in fl1:\n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" if i> 1:\n",
" list1.append(line)\n",
" id = line[0]\n",
" if id in dict2.keys() and dict2[id][4] == group:\n",
" dict3.setdefault(id,{})\n",
" dict3[id]['name'] = dict2[id][0]\n",
" dict3[id]['phone'] = dict2[id][2]\n",
" dict3[id]['unit'] = dict2[id][1]\n",
" dict3[id]['nick'] = dict2[id][3]\n",
" dict3[id]['sc'] = line[6] \n",
" i +=1\n",
"\n",
"list1 = []\n",
"for k, v in dict3.items():\n",
" list2 = []\n",
" if 'dk' in v.keys():\n",
" dk = v['dk']\n",
" else:\n",
" dk = 0\n",
" if 'sc' in v.keys():\n",
" sc = v['sc']\n",
" else:\n",
" sc = ''\n",
" list2 = [k,v['name'],v['phone'],v['unit'],dk,sc]\n",
" list1.append(list2)\n",
"title = ['昵称','姓名','手机号','部门','打卡次数','累计学习时长']\n",
"filename = 'data/交警支队学习情况表221018.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list1:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename) "
]
},
{
"cell_type": "markdown",
"id": "e83be6f5-c05a-4ac0-8511-2dabf770466c",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-18T06:28:39.091613Z",
"iopub.status.busy": "2022-10-18T06:28:39.091059Z",
"iopub.status.idle": "2022-10-18T06:28:39.098295Z",
"shell.execute_reply": "2022-10-18T06:28:39.096326Z",
"shell.execute_reply.started": "2022-10-18T06:28:39.091564Z"
}
},
"source": [
"### 核对新增人员"
]
},
{
"cell_type": "code",
"execution_count": 75,
"id": "a4886e66-99d1-4f24-9d53-29a239e62bad",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-18T09:22:14.008683Z",
"iopub.status.busy": "2022-10-18T09:22:14.008151Z",
"iopub.status.idle": "2022-10-18T09:22:14.070260Z",
"shell.execute_reply": "2022-10-18T09:22:14.068944Z",
"shell.execute_reply.started": "2022-10-18T09:22:14.008634Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"import os\n",
"import glob\n",
"import csv\n",
"import re\n",
"\n",
"filename = 'data/交警支队小鹅通信息221010.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"dict2 = {}\n",
"for k, v in dict1.items():\n",
" if 'id' in v.keys():\n",
" dict2[v['id']] = [v['name'],v['unit'],k,v['nick'],v['group']] \n",
" \n",
"dict3 = {} \n",
"fi_path = 'data/交警支队/打卡/'\n",
"fl = glob.glob(f'{fi_path}*.csv')\n",
"list1 = []\n",
"for fn in fl:\n",
" with open(fn,'r',newline='') as csv_file:\n",
" fl1 = csv.reader(csv_file,delimiter=',')\n",
" group = re.findall(r'百日筑基-(.+)》',fn)[0]\n",
" header = next(fl1)\n",
" for line in fl1:\n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" id = line[0]\n",
" num = line[10]\n",
" #print(id,num)\n",
" if id not in dict2.keys():\n",
" dict3.setdefault(id,{})\n",
" dict3[id]['name'] = line[4]\n",
" dict3[id]['phone'] = line[5]\n",
" dict3[id]['nick'] = line[1]\n",
" \n",
"fi_path = 'data/交警支队/时长/'\n",
"fl = glob.glob(f'{fi_path}*.csv')\n",
"\n",
"list1 = []\n",
"for fn in fl:\n",
" with open(fn,'r',newline='',encoding='gb18030') as csv_file:\n",
" fl1 = csv.reader(csv_file,delimiter=',')\n",
" group = re.findall(r'《(.+)》',fn)[0]\n",
" #header = next(fl1)\n",
" i = 0\n",
" for line in fl1:\n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" if i> 1:\n",
" \n",
" id = line[0]\n",
" if id not in dict2.keys():\n",
" dict3.setdefault(id,{})\n",
" dict3[id]['name'] = line[10]\n",
" dict3[id]['phone'] = line[11]\n",
" dict3[id]['nick'] = line[1] \n",
" i +=1\n",
"#print(dict3)\n",
"for k, v in dict3.items():\n",
" phone = re.sub('[\\r\\n\\f\\t ]{1,}', '',v['phone'])\n",
" if phone in dict1.keys():\n",
" dict1[phone]['id'] = k\n",
" dict1[phone]['nick'] = v['nick'] \n",
" dict1[phone]['user'] = v['name']\n",
" else:\n",
" list1.append([k,v['name'],v['nick'],phone])\n",
"filename = 'data/交警支队小鹅通信息221018.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n",
"\n",
"title = ['id','姓名','昵称','手机号']\n",
"filename = 'data/新增人员表221018.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list1:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename) \n",
"print('ok')"
]
},
{
"cell_type": "code",
"execution_count": 57,
"id": "ee4bb827-287f-4b1f-8dbd-d595cb010892",
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-18T09:03:41.966475Z",
"iopub.status.busy": "2022-10-18T09:03:41.965956Z",
"iopub.status.idle": "2022-10-18T09:03:42.048247Z",
"shell.execute_reply": "2022-10-18T09:03:42.047389Z",
"shell.execute_reply.started": "2022-10-18T09:03:41.966426Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 u_6173e42182911_TnumhwOZG9 子墨 李文静 13718887655\n",
"2 u_6162ec35ad7b7_ey2oOCfUP7 小新卖蜡笔? 高峻超 17860246118\n",
"3 u_lp_1663297930_6323e98a33794_jNgzRD 冬日 冬日 \n",
"4 u_631899e2ad8f9_MhSqCAUX9R 手机尾号0101用户 伴着幸福的人 13605330101\n",
"5 u_6159638142ba1_S9otgjwjX7 宗瑾 宗瑾 18801062497\n",
"6 u_5f05c79ebb792_GDNNK8BWSI 奇奇 亓玉芬 15210715398\n",
"7 u_lp_1663134862_63216c8e0cf6d_5J5DmF 王青 王青 18615337165\n",
"8 u_lp_1663141739_6321876b2363b_S78cx0 霖山听海 霖山听海 \n",
"9 u_lp_1663326669_632459cda856f_GjFOVL 淄博最后的ikun 淄博最后的ikun \n",
"10 u_lp_1663413836_6325ae4cbb828_HSEYyB 妮妮 妮妮 13953380271\n",
"11 u_lp_1663554446_6327d38ef1069_MD1305 XZJ \n",
"12 u_lp_1664171121_63313c71a0f2f_fDvfoo 枕霞旧友 \n",
"13 u_lp_1664546227_6336f5b346d80_TiNiu1 房思春 房思春 \n",
"14 u_lp_1664617172_63380ad429dcb_svfFT3 海涛 祝学迎 13581027888\n",
"15 u_lp_1665225083_6341517b8211a_qiMkIj 阳光zj 阳光zj 13969307666\n",
"16 u_lp_1665641415_6347abc77a7ef_yV6Wox 董凯 董凯 13806481277\n",
"17 u_6319e7da6947f_GN6dmtH3ed 左登峰 左登峰 13964365877\n",
"18 u_lp_1663369088_6324ff80bc705_NgNTWu 我爱我家 \n",
"19 u_lp_1663406890_6325932a5caff_2RIkq2 祁河成 祁河成 \n",
"20 u_lp_1663136362_6321726a8403d_Ht7c9d 王洪珍 王洪珍 \n",
"21 u_6322e3966d41b_rVdSm1pZXH 驀然回首 驀然回首 15953356111\n",
"22 u_6325217365e69_WctQcZFuHb 张红海 张红海 13508951662\n",
"23 u_lp_1662620239_6319924fdf4a4_pB11t3 刘军 \n",
"24 u_lp_1663136658_6321739213909_ttFs3c 朱红霞 朱红霞 \n",
"25 u_lp_1661481758_6308331eaba3a_TQ1j6B 交警 翟峰 交警 翟峰 \n",
"26 u_lp_1663138780_63217bdc3fd19_e8t54f 顺其自然2 \n",
"27 u_lp_1663139478_63217e96c3954_EZvqh2 ???? ???? \n",
"28 u_lp_1664611559_6337f4e73b030_R1Og5Q ???? ???? 13287063721\n",
"29 u_633666862f1b1_XU3mwbtuGf 淬剑 \n",
"30 u_lp_1663119922_632132323da11_n9FmTv 王丽君 王丽君 13475518973\n",
"31 u_lp_1663124329_63214369d8508_N2CO9q 于立霞 于立霞 13953320629\n",
"32 u_lp_1663141198_6321854e76c00_Ab89tb 邓立群 邓立群 \n",
"33 u_lp_1663141485_6321866daf613_4NCc9M 耿晓龙 耿晓龙 \n",
"34 u_lp_1663329993_632466c92bc76_uSmR9Q 孔晓晖 \n",
"35 u_lp_1663551502_6327c80ec1d59_LP3Qr5 梦想成真 梦想成真 15264337301\n",
"36 u_lp_1663634037_63290a75694c9_cbt0Ld 王维军 快乐先行 13869376228\n",
"37 u_lp_1663649808_63294810ce3fd_UEPrNX 刘浩 刘浩 \n",
"38 u_lp_1663722388_632a6394b6954_7SupvO 李传生 李传生 13806431511\n",
"39 u_lp_1664653781_633899d5b97fb_LBp28e 淡若悠然 \n",
"40 u_lp_1661486861_6308470de5d47_QzgTmI 张俊杰 张俊杰 13655339406\n",
"41 u_lp_1664162704_63311b90e964c_jPlmpl 童保华 \n",
"42 u_lp_1665036891_633e725b684d3_hsCm37 刘进 \n",
"43 u_lp_1663142645_63218af5905c5_gqmABq 靥暖 \n",
"44 u_lp_1663225682_6322cf52dde88_qbC3Rs 许志国 \n",
"45 u_lp_1663295972_6323e1e4caea7_fc1HXu 于会萍 \n",
"46 u_lp_1663325439_632454ff8b99b_DrUT6S 孙孝伟 \n",
"47 u_lp_1663555784_6327d8c8c9e25_cLIVK4 便士 便士 \n",
"48 u_lp_1663577491_63282d93ea1e9_JDfOU8 王青海 王青海 \n",
"49 u_lp_1663663112_63297c08977aa_7gPZEP 车西冬 \n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"import os\n",
"import glob\n",
"import csv\n",
"import re\n",
"\n",
"filename = 'data/交警支队小鹅通信息221010.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"dict2 = {}\n",
"for k, v in dict1.items():\n",
" if 'id' in v.keys():\n",
" dict2[v['id']] = [v['name'],v['unit'],k,v['nick'],v['group']] \n",
"dict3 = {} \n",
"fi_path = 'data/交警支队/打卡/'\n",
"fl = glob.glob(f'{fi_path}*.csv')\n",
"list1 = []\n",
"for fn in fl:\n",
" with open(fn,'r',newline='') as csv_file:\n",
" fl1 = csv.reader(csv_file,delimiter=',')\n",
" group = re.findall(r'百日筑基-(.+)》',fn)[0]\n",
" header = next(fl1)\n",
" for line in fl1:\n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" id = line[0]\n",
" num = line[10]\n",
" #print(id,num)\n",
" if id not in dict2.keys():\n",
" dict3.setdefault(id,{})\n",
" dict3[id]['name'] = line[4]\n",
" dict3[id]['phone'] = line[5]\n",
" dict3[id]['nick'] = line[1]\n",
" \n",
"fi_path = 'data/交警支队/时长/'\n",
"fl = glob.glob(f'{fi_path}*.csv')\n",
"\n",
"list1 = []\n",
"for fn in fl:\n",
" with open(fn,'r',newline='',encoding='gb18030') as csv_file:\n",
" fl1 = csv.reader(csv_file,delimiter=',')\n",
" group = re.findall(r'《(.+)》',fn)[0]\n",
" #header = next(fl1)\n",
" i = 0\n",
" for line in fl1:\n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" if i> 1:\n",
" \n",
" id = line[0]\n",
" if id not in dict2.keys():\n",
" dict3.setdefault(id,{})\n",
" dict3[id]['name'] = line[10]\n",
" dict3[id]['phone'] = line[11]\n",
" dict3[id]['nick'] = line[1] \n",
" i +=1\n",
"i = 1\n",
"#print(dict3)\n",
"for k, v in dict3.items():\n",
" phone = re.sub('[\\r\\n\\f\\t ]{1,}', '',v['phone'])\n",
" if phone not in dict1.keys():\n",
" #dict1[phone]['id'] = k\n",
" #dict1[phone]['nick'] = v['nick'] \n",
" #dict1[phone]['user'] = v['name']\n",
" print(i,k,v['nick'], v['name'],phone)\n",
" i+=1\n"
]
},
{
"cell_type": "markdown",
"id": "775a298e-600d-4644-bd43-1eb75a302a9f",
"metadata": {},
"source": [
"### 导出无手机号码人员"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aa15ff39-1527-4f08-9331-d64bd298c1c2",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"filename = 'data/交警支队名单221010.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"for k, v in dict1.items():\n",
" if 'phone' not in v.keys():\n",
" print(v['name'],v['unit'])"
]
},
{
"cell_type": "markdown",
"id": "ef1041a9-2865-4a57-8b4d-1af26f059e22",
"metadata": {},
"source": [
"### 人员部门调整"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7b31ffb5-f5fd-4dbc-b30c-0b583f4c7294",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"wb = openpyxl.load_workbook('data/新部门排序-淄博交警支队人员名单 _56473.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"dict2 = {}\n",
"\n",
"data1 =list(sheet.values)\n",
"del data1[0]\n",
"for item in data1:\n",
" phone = item[4]\n",
" dict2[phone] = [item[1],item[0]]\n",
"#print(dict2)\n",
"dict3 = {}\n",
"filename = 'data/交警支队小鹅通信息.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"for k, v in dict1.items():\n",
" if k not in dict2.keys():\n",
" print(k,dict1[k]['name'])\n",
"#with open(filename, 'w') as fl:\n",
"# json.dump(person, fl, ensure_ascii=False)\n",
"#print('ok')"
]
},
{
"cell_type": "markdown",
"id": "287a2b9a-fc63-44f6-84f7-6228d5e14266",
"metadata": {},
"source": [
"## 核对分组人员情况"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8cf3f2b7-cf8e-47b2-9a8b-7ec5016aeef3",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"\n",
"filename = 'data/交警支队手机号码221010.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
" \n",
"filename = 'data/交警支队分组情况.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",
" phone = line[9]\n",
" group = line[1]\n",
" if phone not in dict1.keys():\n",
" print(line[2],line[9],line[3])\n"
]
},
{
"cell_type": "markdown",
"id": "74e41826-7247-4a5a-99c7-db067dfd6d93",
"metadata": {},
"source": [
"## 核对小鹅通人员"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "765cb3e6-d8ab-4aea-9fb3-9008001b9767",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"\n",
"filename = 'data/交警支队手机号码221010.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/小鹅通人员信息221010.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
" \n",
"for k, v in dict2.items():\n",
" phone = v['phone']\n",
" if phone not in dict1.keys():\n",
" print(k,v['nick'],v['name'],phone)\n",
" \n"
]
},
{
"cell_type": "markdown",
"id": "de4fabec-7ce5-43c8-9019-0a41bf7528d3",
"metadata": {},
"source": [
"### 核对存在多组人员"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "65ef74b4-4667-422c-b610-63b517edd75d",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import os\n",
"import glob\n",
"import csv\n",
"import re\n",
"\n",
"fi_path = 'data/交警支队/时长/'\n",
"fl = glob.glob(f'{fi_path}*.csv')\n",
"\n",
"list1 = []\n",
"dict1 = {}\n",
"for fn in fl:\n",
" with open(fn,'r',newline='',encoding='gb18030') as csv_file:\n",
" fl1 = csv.reader(csv_file,delimiter=',')\n",
" zb = fn.split('-')[3]\n",
" #header = next(fl1)\n",
" i = 0\n",
" for line in fl1:\n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" if i> 1:\n",
" m_id = line[0]\n",
" dict1.setdefault(m_id,[])\n",
" dict1[m_id].append(zb)\n",
" #list1.append(line)\n",
" i +=1\n",
"filename = 'data/交警支队小鹅通信息.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"dict3 = {}\n",
"for k ,v in dict2.items():\n",
" if 'id' in v.keys():\n",
" dict3[v['id']] = [k,v['name'],v['unit'],v['nick']]\n",
"\n",
"for k, v in dict1.items():\n",
" if k in dict3.keys():\n",
" if len(v)>1:\n",
" print(dict3[k][1],dict3[k][2],dict3[k][0],v)\n",
" \n",
" "
]
},
{
"cell_type": "markdown",
"id": "60752c6c-2a55-40ee-997b-bcc286fba054",
"metadata": {},
"source": [
"### 修改json内容"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bcf970ab-b1d6-4da5-80ae-36a8a4bb56be",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"\n",
"\n",
"filename = 'data/交警支队名单221010.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"i = 0\n",
"for k, v in dict1.items():\n",
" if v['unit'] == '支高新区大队':\n",
" dict1[k]['unit'] = '高新区大队'\n",
" i +=1\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl,ensure_ascii=False) \n",
" \n",
"print(f'共有{i}条记录被修改')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ad27154a-ceae-4412-bd87-75d6040eb5d5",
"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
}