This commit is contained in:
512song committed 2023-10-15 14:18:29 +08:00
1 parent 0ed1b60a16
commit 0da5d5e2cd
2 files changed
+251 -96

No files matched your search

+194
View File
@@ -0,0 +1,194 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "04524c85-988e-4dbf-86eb-939a9db7aa28",
"metadata": {},
"source": [
"## 体测人员导入"
]
},
{
"cell_type": "code",
"execution_count": 1,
"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"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/报名登记表142人.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"\n",
"for n in range(2, sheet.max_row+1):\n",
" code = int(sheet.cell(n, 1).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 3).value\n",
" dict1['sex'] = sheet.cell(n, 4).value\n",
" dict1['unit'] = sheet.cell(n, 2).value\n",
" dict1['birth'] = sheet.cell(n,5).value\n",
" person[code] = 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": "048a95aa-1691-45f6-b933-6eaf95ae1d30",
"metadata": {},
"source": [
"## 生成读卡系统文件"
]
},
{
"cell_type": "code",
"execution_count": 2,
"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"
]
}
],
"source": [
"import json\n",
"\n",
"filename = 'data/北京党校.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"for k, v in dict1.items():\n",
" dict2 = {}\n",
" #if dict1['sex'] =='男':\n",
" # sex = 1\n",
" \n",
" dict2 = {'id':k,'name':v['name'],'gender':v['sex'],'birth':v['birth'],'unit':v['unit']}\n",
" list1.append(dict2)\n",
"json_data = json.dumps(list1,ensure_ascii=False, indent=4) \n",
"\n",
"# 将 json 数据写入文件\n",
"with open(\"data/data_北京党校.json\", \"w\",encoding = 'utf-8') as file:\n",
" file.write(json_data) \n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "699c6a40-a6ae-4300-9646-708cb85aa5e8",
"metadata": {},
"source": [
"## 手工数据导入数据库"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "def3f47a-24ef-4815-b63b-2a16b79b4c15",
"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"
},
"tags": []
},
"outputs": [
{
"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"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"filename = 'data/北京党校.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"wb = openpyxl.load_workbook('data/北京党校手工数据.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"dict1 = {}\n",
"dict3 = {1:10,2:11,3:7,4:2,5:6,6:3,7:1}\n",
"sheet = wb.active\n",
"data1 =list(sheet.values)\n",
"del data1[0]\n",
"list1 = []\n",
"for item in data1:\n",
" code = int(item[0])\n",
" list1.append((496534,code,item[2],item[1],'2023-10-15','2023-10-15 14:00:00'))\n",
"print(list1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "67e63f07-3f20-4e0e-9c07-7bf6024eeb4b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}