This commit is contained in:
512song committed 2025-11-07 14:43:16 +08:00
1 parent 2e77e939dd
commit b2ba8722fa
5 files changed
+855 -182

No files matched your search

+136
View File
@@ -0,0 +1,136 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "ce7a7798-b8b7-4564-9e17-3e9c2d4565d8",
"metadata": {},
"source": [
"## 体测人员导入"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "270e8c57-36d3-476c-8c50-4d8bc38a918a",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-07T02:09:01.530591Z",
"iopub.status.busy": "2025-11-07T02:09:01.529883Z",
"iopub.status.idle": "2025-11-07T02:09:01.667299Z",
"shell.execute_reply": "2025-11-07T02:09:01.666813Z",
"shell.execute_reply.started": "2025-11-07T02:09:01.530529Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1287 ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"from datetime import date\n",
"\n",
"wb = openpyxl.load_workbook('data/沧州炼化人员.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"\n",
"for n in range(2, sheet.max_row+1):\n",
" code = sheet.cell(n, 2).value\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 4).value\n",
" dict1['sex'] = sheet.cell(n, 5).value\n",
" dict1['birth'] = str(sheet.cell(n, 6).value).replace('/','-').split(' ')[0] \n",
" dict1['unit'] = sheet.cell(n, 3).value\n",
" dict1['phone'] = str(sheet.cell(n, 7).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(len(person),'ok')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "829d9460-a14e-4689-a7c4-d00bbd8c2e32",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-07T02:21:14.683211Z",
"iopub.status.busy": "2025-11-07T02:21:14.682609Z",
"iopub.status.idle": "2025-11-07T02:21:14.839810Z",
"shell.execute_reply": "2025-11-07T02:21:14.839319Z",
"shell.execute_reply.started": "2025-11-07T02:21:14.683158Z"
}
},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
"from datetime import date\n",
"\n",
"wb = openpyxl.load_workbook('data/沧州炼化人员.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"list1 = []\n",
"list2 = []\n",
"for n in range(2, sheet.max_row+1):\n",
" code = sheet.cell(n, 2).value\n",
" if code not in list1:\n",
" list1.append(code)\n",
" else:\n",
" list2.append(code)\n",
"list3 = []\n",
"for n in range(2, sheet.max_row+1):\n",
" code = sheet.cell(n, 2).value\n",
" if code in list2:\n",
" list4 = [code,sheet.cell(n, 4).value,sheet.cell(n, 3).value]\n",
" list3.append(list4)\n",
"filename = 'data/沧州炼化编号重复人员.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"\n",
"for row in list3:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6c1cfb7b-7252-49ff-97f9-399b658ddf38",
"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.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}