This commit is contained in:
512song committed 2025-10-21 10:14:15 +08:00
1 parent ba6f6b413a
commit a10492f0ad
6 files changed
+1705 -151

No files matched your search

+42 -12
View File
@@ -10,33 +10,48 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "bbba6efc-73cd-4db6-bae7-014724fee731",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-21T02:05:09.966940Z",
"iopub.status.busy": "2025-10-21T02:05:09.966195Z",
"iopub.status.idle": "2025-10-21T02:05:10.249499Z",
"shell.execute_reply": "2025-10-21T02:05:10.248277Z",
"shell.execute_reply.started": "2025-10-21T02:05:09.966870Z"
},
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"270 ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/南化人员信息表.xlsx',data_only=True)\n",
"wb = openpyxl.load_workbook('data/胜利采油厂人员名单.xlsx',data_only=True)\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, 4).value)\n",
" code = int(sheet.cell(n, 2).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 3).value\n",
" dict1['name'] = sheet.cell(n, 4).value\n",
" dict1['sex'] = sheet.cell(n, 5).value\n",
" dict1['unit'] = sheet.cell(n, 2).value \n",
" dict1['unit'] = sheet.cell(n, 3).value \n",
" dict1['birth'] = str(sheet.cell(n, 6).value).replace('/','-').split(' ')[0]\n",
" dict1['phone'] = sheet.cell(n, 12).value \n",
" #dict1['phone'] = sheet.cell(n, 12).value \n",
" person[code] = dict1\n",
"filename = 'data/南京化工人员.json'\n",
"filename = 'data/胜利采油厂人员.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print(len(person),'ok')"
@@ -52,16 +67,31 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "ce406710-6b7d-4c51-98ec-78883bd3ce5f",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-21T02:05:49.362922Z",
"iopub.status.busy": "2025-10-21T02:05:49.362143Z",
"iopub.status.idle": "2025-10-21T02:05:49.376741Z",
"shell.execute_reply": "2025-10-21T02:05:49.375761Z",
"shell.execute_reply.started": "2025-10-21T02:05:49.362862Z"
},
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import json\n",
"\n",
"filename = 'data/南京化工人员.json'\n",
"filename = 'data/胜利采油厂人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
@@ -75,7 +105,7 @@
"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",
"with open(\"data/data_胜利采油厂人员.json\", \"w\",encoding = 'utf-8') as file:\n",
" file.write(json_data) \n",
"print('ok')"
]