This commit is contained in:
512song@sina.com committed 2022-10-02 15:10:40 +08:00
1 parent d7b37d117d
commit ed2a70896c
3 files changed
+380 -70

No files matched your search

+104 -18
View File
@@ -49,6 +49,108 @@
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "eefb520d-0aee-4f92-b6a9-af9efaa88049",
"metadata": {},
"source": [
"### 导出测试成绩"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c1e1b40c-d73a-4e2e-8c22-4d3ae73ede6f",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"items = ['身高','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','年龄','身高','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"filename = 'data/result_2209.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"list1 = []\n",
"for k, v in dict1.items():\n",
" list2 = []\n",
" list2.append(k)\n",
" list2.append(v['name'])\n",
" if 'id' in v.keys(): \n",
" age = v['id'][6:10]+'-'+v['id'][10:12]+'-'+v['id'][12:14]\n",
" else:\n",
" age = v['birth']\n",
" list2.append(age)\n",
" for item in items:\n",
" if item in v.keys():\n",
" list2.append(v[item]['成绩'])\n",
" elif item =='name':\n",
" list2.append(v[item])\n",
" else:\n",
" list2.append('') \n",
" list1.append(list2)\n",
"filename = 'data/2022年安庆得分情况表.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": "code",
"execution_count": 236,
"id": "a3f0d4b9-78c6-4fd2-baf7-a05962e7904c",
"metadata": {
"execution": {
"iopub.execute_input": "2022-09-30T13:02:25.562088Z",
"iopub.status.busy": "2022-09-30T13:02:25.561502Z",
"iopub.status.idle": "2022-09-30T13:02:26.553518Z",
"shell.execute_reply": "2022-09-30T13:02:26.552452Z",
"shell.execute_reply.started": "2022-09-30T13:02:25.562039Z"
}
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"items = ['身高','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','身高','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"filename = 'data/result_2209.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"list1 = []\n",
"for k, v in dict1.items():\n",
" list2 = []\n",
" list2.append(k)\n",
" list2.append(v['name'])\n",
" \n",
" for item in items:\n",
" if item in v.keys():\n",
" list2.append(v[item]['成绩'])\n",
" elif item =='name':\n",
" list2.append(v[item])\n",
" else:\n",
" list2.append('') \n",
" list1.append(list2)\n",
"filename = 'data/2022年安庆得分情况表.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": "e5aa1bf4-c68c-4843-a9fb-c3fe48ff1f39",
@@ -114,30 +216,14 @@
},
{
"cell_type": "code",
"execution_count": 226,
"execution_count": null,
"id": "a00ec014-a4e5-4f8f-9cd5-7b3bd736ad85",
"metadata": {
"execution": {
"iopub.execute_input": "2022-09-27T14:02:23.012372Z",
"iopub.status.busy": "2022-09-27T14:02:23.011852Z",
"iopub.status.idle": "2022-09-27T14:02:23.095005Z",
"shell.execute_reply": "2022-09-27T14:02:23.093941Z",
"shell.execute_reply.started": "2022-09-27T14:02:23.012324Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1892 马向东 该人员已经测试!\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"import operator\n",
"\n",
"filename = '../item.json'\n",
"item = {}\n",
+175 -50
View File
@@ -103,6 +103,83 @@
"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",
@@ -167,11 +244,11 @@
"import openpyxl\n",
"import json\n",
"\n",
"filename = 'data/小鹅通人员信息.json'\n",
"filename = 'data/交警支队小鹅通信息.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"\n",
"wb = openpyxl.load_workbook('data/交警支队小鹅通中手机信息存在问题用户(修正).xlsx')\n",
"wb = openpyxl.load_workbook('data/交警支队小鹅通中手机信息存在问题用户(修正)0930.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"\n",
@@ -180,7 +257,10 @@
" break\n",
" else:\n",
" phone = sheet.cell(n, 4).value\n",
" dict2[sheet.cell(n, 1).value]['phone'] = phone\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",
@@ -303,6 +383,64 @@
" json.dump(dict1, fl,ensure_ascii=False) "
]
},
{
"cell_type": "markdown",
"id": "ab95da60-39b7-4c6b-9ef1-9a1d5d8cccc4",
"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": "dc856c16-3ff0-4c24-a5ee-062129698e08",
@@ -313,27 +451,19 @@
},
{
"cell_type": "code",
"execution_count": 92,
"execution_count": 128,
"id": "c1a5aaef-70be-4fd2-9384-983aeb59f491",
"metadata": {
"execution": {
"iopub.execute_input": "2022-09-29T12:20:48.500293Z",
"iopub.status.busy": "2022-09-29T12:20:48.499768Z",
"iopub.status.idle": "2022-09-29T12:20:48.627177Z",
"shell.execute_reply": "2022-09-29T12:20:48.626065Z",
"shell.execute_reply.started": "2022-09-29T12:20:48.500245Z"
"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": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['data/交警支队/时长/2022-09-29-《气虚组》-视频学习详情_085022.csv', 'data/交警支队/时长/2022-09-28-《阳虚组》-视频学习详情_162739.csv', 'data/交警支队/时长/2022-09-29-《阴虚组》-视频学习详情_084653.csv', 'data/交警支队/时长/2022-09-28-《气郁组》-视频学习详情_155229.csv', 'data/交警支队/时长/2022-09-29-《痰湿组》-视频学习详情_084809.csv', 'data/交警支队/时长/2022-09-28-《血瘀组》-视频学习详情_163202.csv', 'data/交警支队/时长/2022-09-28-《特禀组》-视频学习详情_162914.csv', 'data/交警支队/时长/2022-09-29-《平和组》-视频学习详情_085511.csv', 'data/交警支队/时长/2022-09-29-《湿热组》-视频学习详情_084926.csv']\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"import os\n",
@@ -347,56 +477,51 @@
"dict2 = {}\n",
"for k, v in dict1.items():\n",
" if 'id' in v.keys():\n",
" dict2[v['nick']] = [v['name'],v['unit'],k] \n",
" dict2[v['id']] = [v['name'],v['unit'],k,v['nick'],v['group']] \n",
"dict3 = {} \n",
"fi_path = 'data/交警支队/'\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='gbk') as csv_file:\n",
" with open(fn,'r',newline='') as csv_file:\n",
" fl1 = csv.reader(csv_file,delimiter=',')\n",
" #header = next(fl1)\n",
" i = 0\n",
" header = next(fl1)\n",
" for line in fl1: \n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" if i> 1:\n",
" list1.append(line)\n",
" i +=1\n",
"for item in list1:\n",
" name = item.pop(0)\n",
" num = item.count('√')\n",
" if name in dict2.keys():\n",
" dict3.setdefault(name,{})\n",
" dict3[name]['name'] = dict2[name][0]\n",
" dict3[name]['phone'] = dict2[name][2]\n",
" dict3[name]['unit'] = dict2[name][1]\n",
" if 'dk' in dict3[name].keys():\n",
" dict3[name]['dk'] = num + dict3[name]['dk']\n",
" else:\n",
" dict3[name]['dk'] = num\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",
"print(fl)\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",
"for item in list1:\n",
" name = item[1]\n",
" num = item[2].strip()\n",
" if name in dict2.keys():\n",
" dict3.setdefault(name,{})\n",
" dict3[name]['name'] = dict2[name][0]\n",
" dict3[name]['phone'] = dict2[name][2]\n",
" dict3[name]['unit'] = dict2[name][1]\n",
" dict3[name]['sc'] = num \n",
"\n",
"list1 = []\n",
"for k, v in dict3.items():\n",
" list2 = []\n",
@@ -411,7 +536,7 @@
" list2 = [k,v['name'],v['phone'],v['unit'],dk,sc]\n",
" list1.append(list2)\n",
"title = ['昵称','姓名','手机号','部门','打卡次数','累计学习时长']\n",
"filename = 'data/交警支队学习情况表.xlsx'\n",
"filename = 'data/交警支队学习情况表1.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
+101 -2
View File
@@ -57,6 +57,13 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2022-09-30T14:14:46.100665Z",
"iopub.status.busy": "2022-09-30T14:14:46.100139Z",
"iopub.status.idle": "2022-09-30T14:14:46.109863Z",
"shell.execute_reply": "2022-09-30T14:14:46.108679Z",
"shell.execute_reply.started": "2022-09-30T14:14:46.100616Z"
},
"tags": []
},
"outputs": [],
@@ -74,6 +81,99 @@
"print(list1)"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-02T01:11:16.449789Z",
"iopub.status.busy": "2022-10-02T01:11:16.449246Z",
"iopub.status.idle": "2022-10-02T01:11:16.458463Z",
"shell.execute_reply": "2022-10-02T01:11:16.457216Z",
"shell.execute_reply.started": "2022-10-02T01:11:16.449740Z"
},
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"('5', '10', '48')"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import re\n",
"t = '5小时10分48秒'\n",
"m = re.match(r'(.*)小时(.*)分(.*)秒', t)\n",
"m.groups()"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-02T01:20:50.471217Z",
"iopub.status.busy": "2022-10-02T01:20:50.470675Z",
"iopub.status.idle": "2022-10-02T01:20:50.482522Z",
"shell.execute_reply": "2022-10-02T01:20:50.481212Z",
"shell.execute_reply.started": "2022-10-02T01:20:50.471168Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0, '10', '48']\n"
]
}
],
"source": [
"import re\n",
"t = '10分48秒'\n",
"list1 = []\n",
"if '小时' in t and '分' in t:\n",
" m = re.match(r'(.*)小时(.*)分(.*)秒', t)\n",
" list1 = [m[1],m[2],m[3]]\n",
"elif '小时' in t:\n",
" m = re.match(r'(.*)小时(.*)秒', t)\n",
" list1 = [m[1],0,m[2]]\n",
"elif '分' in t:\n",
" m = re.match(r'(.*)分(.*)秒', t)\n",
" list1 = [0,m[1],m[2]]\n",
"print(list1)\n",
"#m.group()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2022-09-30T14:22:32.892529Z",
"iopub.status.busy": "2022-09-30T14:22:32.892006Z",
"iopub.status.idle": "2022-09-30T14:22:32.900751Z",
"shell.execute_reply": "2022-09-30T14:22:32.898954Z",
"shell.execute_reply.started": "2022-09-30T14:22:32.892480Z"
},
"tags": []
},
"outputs": [],
"source": [
"import re\n",
"\n",
"s = '2022-09-28-《气郁组》-视频学习详情_155229'\n",
"m = re.findall(r'《(.+)》',s)\n",
"print(m)"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -397,7 +497,6 @@
{
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
@@ -1230,7 +1329,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2022-06-30T01:50:36.294943Z",