This commit is contained in:
512song committed 2024-06-09 23:51:24 +08:00
1 parent 94984bf7a6
commit 76487f10e8
4 files changed
+3971 -253

No files matched your search

+63 -73
View File
@@ -10,15 +10,15 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 22,
"id": "ed6c774c-e91d-4f99-9a38-318fade9e937",
"metadata": {
"execution": {
"iopub.execute_input": "2024-06-01T08:38:50.009649Z",
"iopub.status.busy": "2024-06-01T08:38:50.009121Z",
"iopub.status.idle": "2024-06-01T08:38:50.151368Z",
"shell.execute_reply": "2024-06-01T08:38:50.150654Z",
"shell.execute_reply.started": "2024-06-01T08:38:50.009599Z"
"iopub.execute_input": "2024-06-06T02:03:52.715662Z",
"iopub.status.busy": "2024-06-06T02:03:52.714931Z",
"iopub.status.idle": "2024-06-06T02:03:52.870802Z",
"shell.execute_reply": "2024-06-06T02:03:52.870264Z",
"shell.execute_reply.started": "2024-06-06T02:03:52.715592Z"
}
},
"outputs": [
@@ -30,6 +30,49 @@
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"import datetime\n",
"\n",
"wb = openpyxl.load_workbook('data/中安联合体测花名册.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"for n in range(2, sheet.max_row+1):\n",
" if sheet.cell(n,2).value is None:\n",
" break\n",
" else: \n",
" code = int(sheet.cell(n, 4).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 6).value \n",
" xb = str(sheet.cell(n, 7).value)\n",
" if xb == '1':\n",
" sex = '男'\n",
" elif xb =='2':\n",
" sex = '女'\n",
" dict1['sex'] = sex\n",
" dict1['unit'] = sheet.cell(n, 3).value\n",
" rq = str(sheet.cell(n,8).value).split(' ')[0].replace('/','-')\n",
" dt = datetime.datetime.strptime(rq, '%Y-%m-%d')\n",
" dict1['birth'] = dt.strftime('%Y-%m-%d')\n",
" if sheet.cell(n,9).value is not None:\n",
" dict1['phone'] = str(sheet.cell(n,9).value)\n",
" \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": "3239aae7-bcdc-468a-aa68-6b5ca4ff0821",
"metadata": {},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
@@ -53,12 +96,8 @@
" sex = '女'\n",
" dict1['sex'] = sex\n",
" dict1['unit'] = sheet.cell(n, 3).value\n",
" dict1['birth'] = str(sheet.cell(n,8).value).split(' ')[0]\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')"
" rq = str(sheet.cell(n,8).value).split(' ')[0].replace('/','-')\n",
" print(rq,type(rq))"
]
},
{
@@ -71,17 +110,9 @@
},
{
"cell_type": "code",
"execution_count": 44,
"execution_count": null,
"id": "c9430854-6f56-4854-bc6b-d22f812f6715",
"metadata": {
"execution": {
"iopub.execute_input": "2024-05-31T12:41:21.160561Z",
"iopub.status.busy": "2024-05-31T12:41:21.159834Z",
"iopub.status.idle": "2024-05-31T12:41:21.433867Z",
"shell.execute_reply": "2024-05-31T12:41:21.433333Z",
"shell.execute_reply.started": "2024-05-31T12:41:21.160496Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"import openpyxl\n",
@@ -112,17 +143,9 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": null,
"id": "dbc5af3a-1a2a-4094-ac89-f8efded12245",
"metadata": {
"execution": {
"iopub.execute_input": "2024-05-26T09:11:07.788399Z",
"iopub.status.busy": "2024-05-26T09:11:07.787797Z",
"iopub.status.idle": "2024-05-26T09:11:08.056837Z",
"shell.execute_reply": "2024-05-26T09:11:08.056306Z",
"shell.execute_reply.started": "2024-05-26T09:11:07.788344Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"import re\n",
@@ -164,27 +187,10 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "1efe2b78-dd18-4d12-8bc9-058f6f0046c9",
"metadata": {
"execution": {
"iopub.execute_input": "2024-06-01T08:40:42.686238Z",
"iopub.status.busy": "2024-06-01T08:40:42.685496Z",
"iopub.status.idle": "2024-06-01T08:40:42.743042Z",
"shell.execute_reply": "2024-06-01T08:40:42.742507Z",
"shell.execute_reply.started": "2024-06-01T08:40:42.686153Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"709\n",
"709\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import time\n",
@@ -204,7 +210,7 @@
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/places_result_20240601.csv'\n",
"filename = 'data/places_result_20240605.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
@@ -242,17 +248,9 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "dd6379bf-6a79-48de-b3fb-35e84f192ce2",
"metadata": {
"execution": {
"iopub.execute_input": "2024-06-01T08:41:07.934988Z",
"iopub.status.busy": "2024-06-01T08:41:07.934276Z",
"iopub.status.idle": "2024-06-01T08:41:08.095312Z",
"shell.execute_reply": "2024-06-01T08:41:08.094771Z",
"shell.execute_reply.started": "2024-06-01T08:41:07.934919Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"import json\n",
@@ -305,17 +303,9 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"id": "314f9709-4c13-4f8b-bca6-fc2122a9054e",
"metadata": {
"execution": {
"iopub.execute_input": "2024-06-02T01:04:12.743929Z",
"iopub.status.busy": "2024-06-02T01:04:12.742863Z",
"iopub.status.idle": "2024-06-02T01:04:12.793583Z",
"shell.execute_reply": "2024-06-02T01:04:12.792951Z",
"shell.execute_reply.started": "2024-06-02T01:04:12.743871Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"import json\n",