This commit is contained in:
512song committed 2023-10-20 12:40:57 +00:00
1 parent 8c0674106d
commit 626973d224
1 file changed
+50 -27
+50 -27
View File
@@ -10,15 +10,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 9,
"id": "bbba6efc-73cd-4db6-bae7-014724fee731", "id": "bbba6efc-73cd-4db6-bae7-014724fee731",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2023-10-19T05:28:58.387684Z", "iopub.execute_input": "2023-10-20T09:14:31.635091Z",
"iopub.status.busy": "2023-10-19T05:28:58.387380Z", "iopub.status.busy": "2023-10-20T09:14:31.634228Z",
"iopub.status.idle": "2023-10-19T05:28:58.432285Z", "iopub.status.idle": "2023-10-20T09:14:31.688961Z",
"shell.execute_reply": "2023-10-19T05:28:58.430760Z", "shell.execute_reply": "2023-10-20T09:14:31.687120Z",
"shell.execute_reply.started": "2023-10-19T05:28:58.387657Z" "shell.execute_reply.started": "2023-10-20T09:14:31.635013Z"
}, },
"tags": [] "tags": []
}, },
@@ -46,6 +46,7 @@
" person.setdefault(code, {})\n", " person.setdefault(code, {})\n",
" dict1 = {}\n", " dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 2).value\n", " dict1['name'] = sheet.cell(n, 2).value\n",
" dict1['unit'] = '政法委'\n",
" dict1['sex'] = sheet.cell(n, 3).value\n", " dict1['sex'] = sheet.cell(n, 3).value\n",
" dict1['birth'] = str(sheet.cell(n,4).value).split(' ')[0]\n", " dict1['birth'] = str(sheet.cell(n,4).value).split(' ')[0]\n",
" if sheet.cell(n,5).value is not None:\n", " if sheet.cell(n,5).value is not None:\n",
@@ -121,15 +122,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 10,
"id": "970e171e-1360-448f-a28c-520ccb8f314a", "id": "970e171e-1360-448f-a28c-520ccb8f314a",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2023-10-18T02:17:23.733390Z", "iopub.execute_input": "2023-10-20T09:14:46.683022Z",
"iopub.status.busy": "2023-10-18T02:17:23.733131Z", "iopub.status.busy": "2023-10-20T09:14:46.681792Z",
"iopub.status.idle": "2023-10-18T02:17:23.758353Z", "iopub.status.idle": "2023-10-20T09:14:46.726814Z",
"shell.execute_reply": "2023-10-18T02:17:23.757550Z", "shell.execute_reply": "2023-10-20T09:14:46.724006Z",
"shell.execute_reply.started": "2023-10-18T02:17:23.733366Z" "shell.execute_reply.started": "2023-10-20T09:14:46.682951Z"
}, },
"tags": [] "tags": []
}, },
@@ -138,8 +139,8 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"141\n", "25\n",
"141\n" "25\n"
] ]
} }
], ],
@@ -158,11 +159,11 @@
"re_ta = {}\n", "re_ta = {}\n",
"dict1 = {}\n", "dict1 = {}\n",
"list1 = []\n", "list1 = []\n",
"filename = 'data/北京党校.json'\n", "filename = 'data/政法委.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n", " dict1 = json.load(fl) \n",
"\n", "\n",
"filename = 'data/places_result_20231018.csv'\n", "filename = 'data/places_result_20231020.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n", "with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n", " fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n", " header = next(fl) \n",
@@ -183,7 +184,7 @@
" score = int(result[4])/item[m_item]['divisor'] \n", " score = int(result[4])/item[m_item]['divisor'] \n",
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n", " re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
"print(len(re_ta))\n", "print(len(re_ta))\n",
"filename = 'data/result_北京党校.json'\n", "filename = 'data/result_政法委.json'\n",
"\n", "\n",
"with open(filename,'w') as fl:\n", "with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n", " json.dump(re_ta, fl, ensure_ascii=False) \n",
@@ -200,9 +201,16 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 12,
"id": "867ad6b0-9e9d-48bc-a10a-3b9cb6125890", "id": "867ad6b0-9e9d-48bc-a10a-3b9cb6125890",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-10-20T09:16:05.643852Z",
"iopub.status.busy": "2023-10-20T09:16:05.643571Z",
"iopub.status.idle": "2023-10-20T09:16:05.697130Z",
"shell.execute_reply": "2023-10-20T09:16:05.695645Z",
"shell.execute_reply.started": "2023-10-20T09:16:05.643830Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [],
@@ -211,13 +219,13 @@
"import openpyxl\n", "import openpyxl\n",
"\n", "\n",
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"\n", "\n",
"filename = 'data/result_北京党校.json'\n", "filename = 'data/result_政法委.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n", " dict1 = json.load(fl)\n",
"\n", "\n",
"filename = 'data/北京党校.json'\n", "filename = 'data/政法委.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n", " dict2 = json.load(fl)\n",
" \n", " \n",
@@ -236,7 +244,7 @@
" else:\n", " else:\n",
" list2.append('') \n", " list2.append('') \n",
" list1.append(list2)\n", " list1.append(list2)\n",
"filename = 'data/北京党校.xlsx'\n", "filename = 'data/政法委.xlsx'\n",
"wb = openpyxl.Workbook()\n", "wb = openpyxl.Workbook()\n",
"sheet = wb.active\n", "sheet = wb.active\n",
"sheet.append(title)\n", "sheet.append(title)\n",
@@ -256,20 +264,35 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 8,
"id": "def3f47a-24ef-4815-b63b-2a16b79b4c15", "id": "def3f47a-24ef-4815-b63b-2a16b79b4c15",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-10-20T09:07:18.193797Z",
"iopub.status.busy": "2023-10-20T09:07:18.193078Z",
"iopub.status.idle": "2023-10-20T09:07:18.226391Z",
"shell.execute_reply": "2023-10-20T09:07:18.225076Z",
"shell.execute_reply.started": "2023-10-20T09:07:18.193731Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[(496535, 2, 5, 3, '2023-10-20', '2023-10-20 17:00:00'), (496535, 8, 5, 20, '2023-10-20', '2023-10-20 17:00:00'), (496535, 42, 5, 29, '2023-10-20', '2023-10-20 17:00:00'), (496535, 22, 5, 30, '2023-10-20', '2023-10-20 17:00:00'), (496535, 21, 5, 43, '2023-10-20', '2023-10-20 17:00:00'), (496535, 12, 5, 20, '2023-10-20', '2023-10-20 17:00:00'), (496535, 4, 5, 38, '2023-10-20', '2023-10-20 17:00:00'), (496535, 30, 5, 10, '2023-10-20', '2023-10-20 17:00:00'), (496535, 2, 3, -118, '2023-10-20', '2023-10-20 17:00:00')]\n"
]
}
],
"source": [ "source": [
"import openpyxl\n", "import openpyxl\n",
"import json\n", "import json\n",
"\n", "\n",
"filename = 'data/北京党校.json'\n", "filename = 'data/政法委.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n", " dict2 = json.load(fl)\n",
"wb = openpyxl.load_workbook('data/北京党校手工数据.xlsx')\n", "wb = openpyxl.load_workbook('data/政法委手工数据.xlsx')\n",
"sheet = wb.active\n", "sheet = wb.active\n",
"# sheets = wb.sheetnames\n", "# sheets = wb.sheetnames\n",
"dict1 = {}\n", "dict1 = {}\n",
@@ -280,7 +303,7 @@
"list1 = []\n", "list1 = []\n",
"for item in data1:\n", "for item in data1:\n",
" code = int(item[0])\n", " code = int(item[0])\n",
" list1.append((496534,code,item[2],item[1],'2023-10-15','2023-10-15 14:00:00'))\n", " list1.append((496535,code,item[2],item[1],'2023-10-20','2023-10-20 17:00:00'))\n",
"print(list1)" "print(list1)"
] ]
}, },