diff --git a/体测单位/淄博交警支队.ipynb b/体测单位/淄博交警支队.ipynb index b439b4e..7a228b4 100644 --- a/体测单位/淄博交警支队.ipynb +++ b/体测单位/淄博交警支队.ipynb @@ -108,49 +108,6 @@ " json.dump(dict1, fl,ensure_ascii=False) " ] }, - { - "cell_type": "markdown", - "id": "3537ca04-4d1c-4432-8321-98d38069c065", - "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": "fa233427-c1ea-4005-a2bd-b2b9e94604d0", @@ -198,48 +155,6 @@ "print('ok')" ] }, - { - "cell_type": "markdown", - "id": "234d9b71-f99e-48cb-af9b-151bbf3f1715", - "metadata": {}, - "source": [ - "### 小鹅通人员分组(按照手机号关联)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "9aaa35a7-13e2-4ece-a9fd-931ad00e89d3", - "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", - "\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/交警支队小鹅通信息221010.json'\n", - "with open(filename,'w') as fl:\n", - " json.dump(dict1, fl,ensure_ascii=False) " - ] - }, { "cell_type": "markdown", "id": "c61f18ab-7411-44d4-9741-3dd50283f4bb", @@ -290,60 +205,44 @@ }, { "cell_type": "markdown", - "id": "8136ea7b-d485-452d-b032-0cfa538166a9", + "id": "234d9b71-f99e-48cb-af9b-151bbf3f1715", "metadata": {}, "source": [ - "### 修正人员信息" + "### 小鹅通人员分组(按照手机号关联)" ] }, { "cell_type": "code", - "execution_count": 193, - "id": "5678472e-b131-4940-9161-240dcd3461bb", + "execution_count": null, + "id": "9aaa35a7-13e2-4ece-a9fd-931ad00e89d3", "metadata": { - "execution": { - "iopub.execute_input": "2022-10-10T06:18:42.971929Z", - "iopub.status.busy": "2022-10-10T06:18:42.971397Z", - "iopub.status.idle": "2022-10-10T06:18:43.018769Z", - "shell.execute_reply": "2022-10-10T06:18:43.017656Z", - "shell.execute_reply.started": "2022-10-10T06:18:42.971881Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ok\n" - ] - } - ], + "outputs": [], "source": [ - "import openpyxl\n", "import json\n", + "import csv\n", "\n", "filename = 'data/交警支队小鹅通信息221010.json'\n", "with open(filename,'r') as fl:\n", - " dict2 = json.load(fl) \n", + " dict1 = json.load(fl) \n", "\n", - "wb = openpyxl.load_workbook('data/交警支队小鹅通中手机信息存在问题用户(修正)1010.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, 2).value\n", - " dict2[phone]['user'] = sheet.cell(n, 3).value\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", - "with open(filename, 'w') as fl:\n", - " json.dump(dict2, fl, ensure_ascii=False)\n", - "print('ok')" + "filename = 'data/交警支队小鹅通信息221010.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(dict1, fl,ensure_ascii=False) " ] }, { @@ -394,67 +293,45 @@ }, { "cell_type": "markdown", - "id": "cd83bd12-996d-43f6-8589-ba93596670cd", + "id": "8136ea7b-d485-452d-b032-0cfa538166a9", "metadata": {}, "source": [ - "#### 关联人员分组至小鹅通" + "### 修正人员信息" ] }, { "cell_type": "code", "execution_count": null, - "id": "e5737104-ac16-4529-b12b-a32b80f9d040", + "id": "5678472e-b131-4940-9161-240dcd3461bb", "metadata": { "tags": [] }, "outputs": [], "source": [ + "import openpyxl\n", "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 dict1.items():\n", - " if 'phone' in v.keys() and 'group' in v.keys():\n", - " phone = v['phone']\n", + "wb = openpyxl.load_workbook('data/交警支队小鹅通中手机信息存在问题用户(修正)1010.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]['group'] = v['group']\n", + " dict2[phone]['id'] = sheet.cell(n, 1).value\n", + " dict2[phone]['nick'] = sheet.cell(n, 2).value\n", + " dict2[phone]['user'] = sheet.cell(n, 3).value\n", "\n", - "with open(filename,'w') as fl:\n", - " json.dump(dict2, fl,ensure_ascii=False) " - ] - }, - { - "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'])" + "with open(filename, 'w') as fl:\n", + " json.dump(dict2, fl, ensure_ascii=False)\n", + "print('ok')" ] }, { @@ -467,15 +344,15 @@ }, { "cell_type": "code", - "execution_count": 194, + "execution_count": 222, "id": "c1a5aaef-70be-4fd2-9384-983aeb59f491", "metadata": { "execution": { - "iopub.execute_input": "2022-10-10T06:18:48.344784Z", - "iopub.status.busy": "2022-10-10T06:18:48.344254Z", - "iopub.status.idle": "2022-10-10T06:18:48.498589Z", - "shell.execute_reply": "2022-10-10T06:18:48.497580Z", - "shell.execute_reply.started": "2022-10-10T06:18:48.344737Z" + "iopub.execute_input": "2022-10-10T09:17:15.717303Z", + "iopub.status.busy": "2022-10-10T09:17:15.716746Z", + "iopub.status.idle": "2022-10-10T09:17:15.876065Z", + "shell.execute_reply": "2022-10-10T09:17:15.875047Z", + "shell.execute_reply.started": "2022-10-10T09:17:15.717217Z" }, "tags": [] }, @@ -562,6 +439,76 @@ "wb.save(filename) " ] }, + { + "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", @@ -607,48 +554,12 @@ }, { "cell_type": "code", - "execution_count": 190, + "execution_count": null, "id": "765cb3e6-d8ab-4aea-9fb3-9008001b9767", "metadata": { - "execution": { - "iopub.execute_input": "2022-10-10T06:01:12.416957Z", - "iopub.status.busy": "2022-10-10T06:01:12.416440Z", - "iopub.status.idle": "2022-10-10T06:01:12.454328Z", - "shell.execute_reply": "2022-10-10T06:01:12.453384Z", - "shell.execute_reply.started": "2022-10-10T06:01:12.416909Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "u_6300b868354b7_fhNgUKdQgZ 张蓬 张蓬 \n", - "u_lp_1663297930_6323e98a33794_jNgzRD 冬日 冬日 \n", - "u_6300b839aa6b3_JzU0z9mMAy 黄明顺 黄明顺 \n", - "u_6300b7d711a32_V5eLaqp2rv 孟令强 孟令强 13656435666\n", - "u_632274c592a5f_uEtoa2t8L4 王毅 王毅 13853371118\n", - "u_6300b790a0ff7_iVHWce6Il4 博山大队卢娟 卢娟 \n", - "u_6300b7d4bc5a0_ayO3NftEDA 手机尾号3202用户 \n", - "u_6300b7f190dfa_B4wGouLgY8 手机尾号6627用户 不忘初心 13805333711\n", - "u_lp_1663210667_632294ab14915_juLjGd 王晶 王晶 \n", - "u_lp_1663230904_6322e3b86ac92_wcTVgm 志行远野 郑志远 \n", - "u_631899e2ad8f9_MhSqCAUX9R 手机尾号0101用户 伴着幸福的人 13605330101\n", - "u_lp_1663655054_63295c8e069ef_J3IzYt 胡钰 胡钰 \n", - "u_6300b85963d1e_zQEFOZPIp3 吕元东 吕元东 \n", - "u_6300b855855a2_Wx4LEvcB2o 手机尾号6607用户 朱双三 \n", - "u_lp_1663327661_63245dad5f702_I8JfuY 任振华 \n", - "u_6300b8afc9257_mQ2JVzYyNX 张艳 张艳 13864333088\n", - "u_6300b8ca95f42_m9uh26AitM 朱勤东 朱勤东 13953382936\n", - "u_6300b888d3aac_O39r6KCeML 王勇威 王勇威 \n", - "u_lp_1663656013_6329604d16842_DHrc16 石鑫 石鑫 13583336118\n", - "u_lp_1663124568_63214458327d4_lgwfCh 王欣怡 王欣怡 \n", - "u_6300b8a21e3fe_zWo6UFSjrS 宗力 宗力 \n", - "u_lp_1663138566_63217b06daf80_S7mJ25 薛林 薛林 18615331777\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import csv\n", @@ -726,10 +637,44 @@ " " ] }, + { + "cell_type": "markdown", + "id": "60752c6c-2a55-40ee-997b-bcc286fba054", + "metadata": {}, + "source": [ + "### 修改json内容" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "e1c6eb2c-82cc-4d5d-a55b-edda851f995f", + "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": []