109 lines
3.2 KiB
Plaintext
109 lines
3.2 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "bf152e7d-6a36-4877-98d9-f11e3a73792e",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 导入人员信息"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"id": "1b92b7c5-cb77-49da-95b7-34827ecf1d16",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-04-16T09:15:26.090819Z",
|
|
"iopub.status.busy": "2023-04-16T09:15:26.089924Z",
|
|
"iopub.status.idle": "2023-04-16T09:15:28.536339Z",
|
|
"shell.execute_reply": "2023-04-16T09:15:28.535561Z",
|
|
"shell.execute_reply.started": "2023-04-16T09:15:26.090779Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"ok\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"import json\n",
|
|
"\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",
|
|
" if sheet.cell(n,1).value is not None:\n",
|
|
" code = int(sheet.cell(n, 1).value)\n",
|
|
" person.setdefault(code, {})\n",
|
|
" dict1 = {}\n",
|
|
" dict1['name'] = sheet.cell(n, 2).value \n",
|
|
" dict1['sex'] = sheet.cell(n, 3).value\n",
|
|
" birth = str(sheet.cell(n, 6).value).split()[0]\n",
|
|
" dict1['birth'] = birth\n",
|
|
" if sheet.cell(n,5).value is not None:\n",
|
|
" dict1['phone'] = sheet.cell(n, 5).value\n",
|
|
" if sheet.cell(n,7).value is not None:\n",
|
|
" dict1['id_num'] = sheet.cell(n, 7).value\n",
|
|
" if sheet.cell(n,8).value is not None:\n",
|
|
" dict1['SAP'] = sheet.cell(n, 8).value\n",
|
|
" if sheet.cell(n,9).value is not None:\n",
|
|
" dict1['工作单位'] = sheet.cell(n, 9).value\n",
|
|
" if sheet.cell(n,10).value is not None:\n",
|
|
" dict1['车间'] = sheet.cell(n, 10).value\n",
|
|
" else:\n",
|
|
" dict1['车间'] =''\n",
|
|
" if sheet.cell(n,11).value is not None:\n",
|
|
" dict1['班组'] = sheet.cell(n, 11).value\n",
|
|
" else:\n",
|
|
" dict1['班组'] =''\n",
|
|
" if sheet.cell(n,12).value is not None:\n",
|
|
" dict1['工作性质'] = sheet.cell(n, 11).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": "code",
|
|
"execution_count": null,
|
|
"id": "cccb9f2d-3d3a-4292-9204-55310e2c56d1",
|
|
"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.6"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|