diff --git a/体测单位/淄博交警支队.ipynb b/体测单位/淄博交警支队.ipynb index 9d096ce..b439b4e 100644 --- a/体测单位/淄博交警支队.ipynb +++ b/体测单位/淄博交警支队.ipynb @@ -2,8 +2,17 @@ "cells": [ { "cell_type": "markdown", - "id": "e6a72068-83c7-45ff-a0d4-8ccd9abbc091", - "metadata": {}, + "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": [ "## 人员信息导入" ] @@ -50,296 +59,12 @@ " 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/交警支队名单.json'\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": "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(3, 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/交警支队手机号码.json'\n", - "with open(filename, 'w') as fl:\n", - " json.dump(person, fl, ensure_ascii=False)\n", - "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/交警支队名单1.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", - " code = line[0]\n", - " group = line[1]\n", - " if code in dict1.keys():\n", - " dict1[code]['group'] = group\n", - "\n", - "filename = 'data/交警支队名单1.json'\n", - "with open(filename,'w') as fl:\n", - " json.dump(dict1, fl,ensure_ascii=False) " - ] - }, - { - "cell_type": "markdown", - "id": "421723e5-6102-4dae-bae8-39e58efc427d", - "metadata": {}, - "source": [ - "#### 关联人员分组至小鹅通" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e5737104-ac16-4529-b12b-a32b80f9d040", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "import json\n", - "import csv\n", - "\n", - "filename = 'data/交警支队名单1.json'\n", - "with open(filename,'r') as fl:\n", - " dict1 = json.load(fl) \n", - "\n", - "filename = 'data/交警支队小鹅通信息.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", - " if phone in dict2.keys():\n", - " dict2[phone]['group'] = v['group']\n", - "\n", - "with open(filename,'w') as fl:\n", - " json.dump(dict2, fl,ensure_ascii=False) " - ] - }, - { - "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/交警支队名单.json'\n", - "with open(filename,'r') as fl:\n", - " dict1 = json.load(fl) \n", - "list2 = []\n", - "filename = 'data/交警支队手机号码.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']]\n", - " list2.append(list1)\n", - "for k, v in dict1.items():\n", - " name = v['name']\n", - " unit = v['birth']\n", - " for item in list2:\n", - " if name in item and unit in item:\n", - " dict1[k]['phone'] = item[0]\n", - " \n", - " break\n", - "filename = 'data/交警支队名单1.json'\n", - "with open(filename, 'w') as fl:\n", - " json.dump(dict1, fl, ensure_ascii=False)\n", - "print('ok') \n", - " \n" - ] - }, - { - "cell_type": "markdown", - "id": "8136ea7b-d485-452d-b032-0cfa538166a9", - "metadata": {}, - "source": [ - "### 修正人员信息" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5678472e-b131-4940-9161-240dcd3461bb", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "import openpyxl\n", - "import json\n", - "\n", - "filename = 'data/交警支队小鹅通信息.json'\n", - "with open(filename,'r') as fl:\n", - " dict2 = json.load(fl) \n", - "\n", - "wb = openpyxl.load_workbook('data/交警支队小鹅通中手机信息存在问题用户(修正)0930.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, 4).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", - "\n", - "with open(filename, 'w') as fl:\n", - " json.dump(dict2, fl, ensure_ascii=False)\n", - "print('ok')" - ] - }, - { - "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/交警支队名单1.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/小鹅通人员信息.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/交警支队小鹅通信息.json'\n", - "with open(filename, 'w') as fl:\n", - " json.dump(dict2, fl, ensure_ascii=False)\n", - "print('ok') " - ] - }, - { - "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/交警支队名单1.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": "f684616c-98f2-4f37-81c8-77ab5a7389fa", @@ -367,7 +92,7 @@ "fl = glob.glob(f'{fi_path}*.csv')\n", "list1 = []\n", "for fn in fl:\n", - " with open(fn,'r',newline='') as csv_file:\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", @@ -378,14 +103,574 @@ " dict1[item[0]]['nick'] = item[1]\n", " dict1[item[0]]['name'] = item[4] \n", " dict1[item[0]]['phone'] = item[5] \n", - "filename = 'data/小鹅通人员信息.json'\n", + "filename = 'data/小鹅通人员信息221010.json'\n", "with open(filename,'w') as fl:\n", " json.dump(dict1, fl,ensure_ascii=False) " ] }, { "cell_type": "markdown", - "id": "ab95da60-39b7-4c6b-9ef1-9a1d5d8cccc4", + "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", + "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": "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", + "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": "8136ea7b-d485-452d-b032-0cfa538166a9", + "metadata": {}, + "source": [ + "### 修正人员信息" + ] + }, + { + "cell_type": "code", + "execution_count": 193, + "id": "5678472e-b131-4940-9161-240dcd3461bb", + "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" + ] + } + ], + "source": [ + "import openpyxl\n", + "import json\n", + "\n", + "filename = 'data/交警支队小鹅通信息221010.json'\n", + "with open(filename,'r') as fl:\n", + " dict2 = 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", + "\n", + "with open(filename, 'w') as fl:\n", + " json.dump(dict2, fl, ensure_ascii=False)\n", + "print('ok')" + ] + }, + { + "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": "cd83bd12-996d-43f6-8589-ba93596670cd", + "metadata": {}, + "source": [ + "#### 关联人员分组至小鹅通" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e5737104-ac16-4529-b12b-a32b80f9d040", + "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 dict1.items():\n", + " if 'phone' in v.keys() and 'group' in v.keys():\n", + " phone = v['phone']\n", + " if phone in dict2.keys():\n", + " dict2[phone]['group'] = v['group']\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'])" + ] + }, + { + "cell_type": "markdown", + "id": "dc856c16-3ff0-4c24-a5ee-062129698e08", + "metadata": {}, + "source": [ + "## 打卡信息导入" + ] + }, + { + "cell_type": "code", + "execution_count": 194, + "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" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "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='',encoding='gb18030') as csv_file:\n", + " fl1 = csv.reader(csv_file,delimiter=',')\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():\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/交警支队学习情况表221010.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": "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": 190, + "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" + ] + } + ], + "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": [ "### 核对存在多组人员" @@ -441,123 +726,10 @@ " " ] }, - { - "cell_type": "markdown", - "id": "dc856c16-3ff0-4c24-a5ee-062129698e08", - "metadata": {}, - "source": [ - "## 打卡信息导入" - ] - }, - { - "cell_type": "code", - "execution_count": 128, - "id": "c1a5aaef-70be-4fd2-9384-983aeb59f491", - "metadata": { - "execution": { - "iopub.execute_input": "2022-09-30T15:16:00.175939Z", - "iopub.status.busy": "2022-09-30T15:16:00.175417Z", - "iopub.status.idle": "2022-09-30T15:16:00.308873Z", - "shell.execute_reply": "2022-09-30T15:16:00.307748Z", - "shell.execute_reply.started": "2022-09-30T15:16:00.175891Z" - }, - "tags": [] - }, - "outputs": [], - "source": [ - "import json\n", - "import os\n", - "import glob\n", - "import csv\n", - "import re\n", - "\n", - "filename = 'data/交警支队小鹅通信息.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", - " 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():\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[2] \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/交警支队学习情况表1.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": "74e41826-7247-4a5a-99c7-db067dfd6d93", - "metadata": {}, - "source": [ - "## 学习时长信息导入" - ] - }, { "cell_type": "code", "execution_count": null, - "id": "765cb3e6-d8ab-4aea-9fb3-9008001b9767", + "id": "e1c6eb2c-82cc-4d5d-a55b-edda851f995f", "metadata": {}, "outputs": [], "source": []