20231018
This commit is contained in:
1 parent
3e97205f17
commit
61fd173804
4 files changed
+744
-121
No files matched your search
+135
-44
@@ -10,26 +10,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": null,
|
||||
"id": "bbba6efc-73cd-4db6-bae7-014724fee731",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-14T10:59:21.792059Z",
|
||||
"iopub.status.busy": "2023-10-14T10:59:21.791573Z",
|
||||
"iopub.status.idle": "2023-10-14T10:59:21.924403Z",
|
||||
"shell.execute_reply": "2023-10-14T10:59:21.923914Z",
|
||||
"shell.execute_reply.started": "2023-10-14T10:59:21.792012Z"
|
||||
}
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
@@ -65,27 +51,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": null,
|
||||
"id": "ce406710-6b7d-4c51-98ec-78883bd3ce5f",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-14T11:00:39.153235Z",
|
||||
"iopub.status.busy": "2023-10-14T11:00:39.152837Z",
|
||||
"iopub.status.idle": "2023-10-14T11:00:39.160327Z",
|
||||
"shell.execute_reply": "2023-10-14T11:00:39.159338Z",
|
||||
"shell.execute_reply.started": "2023-10-14T11:00:39.153204Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"\n",
|
||||
@@ -110,23 +81,23 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "699c6a40-a6ae-4300-9646-708cb85aa5e8",
|
||||
"id": "6bcd45c2-10af-4d5f-9e0b-5cd1df4f7a7f",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 手工数据导入数据库"
|
||||
"## 获取人员测试成绩"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "def3f47a-24ef-4815-b63b-2a16b79b4c15",
|
||||
"execution_count": 7,
|
||||
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-15T06:15:31.143651Z",
|
||||
"iopub.status.busy": "2023-10-15T06:15:31.143188Z",
|
||||
"iopub.status.idle": "2023-10-15T06:15:31.160440Z",
|
||||
"shell.execute_reply": "2023-10-15T06:15:31.159756Z",
|
||||
"shell.execute_reply.started": "2023-10-15T06:15:31.143614Z"
|
||||
"iopub.execute_input": "2023-10-18T02:17:23.733390Z",
|
||||
"iopub.status.busy": "2023-10-18T02:17:23.733131Z",
|
||||
"iopub.status.idle": "2023-10-18T02:17:23.758353Z",
|
||||
"shell.execute_reply": "2023-10-18T02:17:23.757550Z",
|
||||
"shell.execute_reply.started": "2023-10-18T02:17:23.733366Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
@@ -135,10 +106,130 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[(496534, 6, 5, 32, '2023-10-15', '2023-10-15 14:00:00'), (496534, 39, 5, 12, '2023-10-15', '2023-10-15 14:00:00'), (496534, 105, 5, 22, '2023-10-15', '2023-10-15 14:00:00'), (496534, 136, 5, 20, '2023-10-15', '2023-10-15 14:00:00'), (496534, 110, 5, 53, '2023-10-15', '2023-10-15 14:00:00'), (496534, 144, 5, 11, '2023-10-15', '2023-10-15 14:00:00'), (496534, 87, 5, 45, '2023-10-15', '2023-10-15 14:00:00'), (496534, 71, 5, 22, '2023-10-15', '2023-10-15 14:00:00'), (496534, 153, 5, 16, '2023-10-15', '2023-10-15 14:00:00'), (496534, 158, 5, 23, '2023-10-15', '2023-10-15 14:00:00'), (496534, 150, 5, 28, '2023-10-15', '2023-10-15 14:00:00'), (496534, 140, 5, 16, '2023-10-15', '2023-10-15 14:00:00'), (496534, 138, 5, 35, '2023-10-15', '2023-10-15 14:00:00'), (496534, 137, 5, 30, '2023-10-15', '2023-10-15 14:00:00'), (496534, 377, 5, 59, '2023-10-15', '2023-10-15 14:00:00'), (496534, 131, 5, 55, '2023-10-15', '2023-10-15 14:00:00'), (496534, 76, 5, 52, '2023-10-15', '2023-10-15 14:00:00'), (496534, 14, 5, 25, '2023-10-15', '2023-10-15 14:00:00'), (496534, 88, 5, 29, '2023-10-15', '2023-10-15 14:00:00'), (496534, 115, 5, 30, '2023-10-15', '2023-10-15 14:00:00'), (496534, 78, 5, 57, '2023-10-15', '2023-10-15 14:00:00'), (496534, 103, 5, 67, '2023-10-15', '2023-10-15 14:00:00'), (496534, 148, 5, 10, '2023-10-15', '2023-10-15 14:00:00'), (496534, 54, 5, 57, '2023-10-15', '2023-10-15 14:00:00'), (496534, 35, 5, 21, '2023-10-15', '2023-10-15 14:00:00'), (496534, 42, 5, 39, '2023-10-15', '2023-10-15 14:00:00'), (496534, 45, 5, 50, '2023-10-15', '2023-10-15 14:00:00'), (496534, 95, 5, 36, '2023-10-15', '2023-10-15 14:00:00'), (496534, 122, 5, 51, '2023-10-15', '2023-10-15 14:00:00'), (496534, 74, 5, 27, '2023-10-15', '2023-10-15 14:00:00'), (496534, 63, 5, 62, '2023-10-15', '2023-10-15 14:00:00'), (496534, 100, 5, 20, '2023-10-15', '2023-10-15 14:00:00'), (496534, 162, 5, 30, '2023-10-15', '2023-10-15 14:00:00'), (496534, 43, 5, 50, '2023-10-15', '2023-10-15 14:00:00'), (496534, 149, 5, 49, '2023-10-15', '2023-10-15 14:00:00'), (496534, 127, 5, 16, '2023-10-15', '2023-10-15 14:00:00'), (496534, 62, 5, 21, '2023-10-15', '2023-10-15 14:00:00'), (496534, 40, 5, 10, '2023-10-15', '2023-10-15 14:00:00'), (496534, 53, 5, 24, '2023-10-15', '2023-10-15 14:00:00')]\n"
|
||||
"141\n",
|
||||
"141\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import time\n",
|
||||
"import csv\n",
|
||||
"\n",
|
||||
"filename = '../item.json'\n",
|
||||
"item = {}\n",
|
||||
"unit = {}\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"for k,v in dict1.items():\n",
|
||||
" item[k] = v\n",
|
||||
"re_ta = {}\n",
|
||||
"dict1 = {}\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/北京党校.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"\n",
|
||||
"filename = 'data/places_result_20231018.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",
|
||||
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
||||
" list1.append(line)\n",
|
||||
"#print(list1)\n",
|
||||
"for result in list1:\n",
|
||||
" user = str(result[2])\n",
|
||||
" if user in dict1.keys(): \n",
|
||||
" m_item = str(result[3]) \n",
|
||||
" re_ta.setdefault(user,{}) \n",
|
||||
" re_ta[user]['name'] = dict1[user]['name']\n",
|
||||
" re_ta[user]['sex'] = dict1[user]['sex'] \n",
|
||||
" re_ta[user]['unit'] = dict1[user]['unit']\n",
|
||||
" item_name = item[m_item]['name']\n",
|
||||
" re_ta[user].setdefault(item_name,{}) \n",
|
||||
" score = int(result[4])/item[m_item]['divisor'] \n",
|
||||
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
||||
"print(len(re_ta))\n",
|
||||
"filename = 'data/result_北京党校.json'\n",
|
||||
"\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||
"print(len(re_ta))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d034a61d-1fbd-417b-99bd-277e43ebb678",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 导出测试人员信息"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "867ad6b0-9e9d-48bc-a10a-3b9cb6125890",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"\n",
|
||||
"filename = 'data/result_北京党校.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",
|
||||
"list1 = []\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" list2 = []\n",
|
||||
" list2.append(str(k).rjust(5,'0'))\n",
|
||||
" list2.append(v['name']) \n",
|
||||
" list2.append(dict2[k]['sex'])\n",
|
||||
" list2.append(dict2[k]['unit'])\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/北京党校.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": "699c6a40-a6ae-4300-9646-708cb85aa5e8",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 手工数据导入数据库"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "def3f47a-24ef-4815-b63b-2a16b79b4c15",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
|
||||
Reference in new issue
Block a user