This commit is contained in:
512song committed 2023-12-18 05:07:31 +00:00
1 parent f47c1db021
commit f5d018a4a3
1 file changed
+79
+79
View File
@@ -4,6 +4,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"id": "e764be85-0ddf-4055-abd6-de2990e75db8", "id": "e764be85-0ddf-4055-abd6-de2990e75db8",
"metadata": { "metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": [], "tags": [],
"toc-hr-collapsed": true "toc-hr-collapsed": true
}, },
@@ -2692,6 +2693,84 @@
"# json.dump(list1, fl, ensure_ascii=False) " "# json.dump(list1, fl, ensure_ascii=False) "
] ]
}, },
{
"cell_type": "markdown",
"id": "72a5c88e-d8b0-473c-b9d1-37c7acbdcf0f",
"metadata": {},
"source": [
"## 核对网上问卷人员信息"
]
},
{
"cell_type": "code",
"execution_count": 99,
"id": "ca0780fe-5d74-4d4e-ad1d-38813040c778",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-18T04:51:12.263717Z",
"iopub.status.busy": "2023-12-18T04:51:12.263362Z",
"iopub.status.idle": "2023-12-18T04:51:12.512393Z",
"shell.execute_reply": "2023-12-18T04:51:12.511795Z",
"shell.execute_reply.started": "2023-12-18T04:51:12.263685Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"\n",
"dict1 = {}\n",
"\n",
"filename = 'data/天津石化人员名单2023.json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl)\n",
"\n",
"\n",
"list1 = []\n",
"filename = 'data/Survey_20231218.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
" for line in fl:\n",
" list1.append(line)\n",
"list2 = []\n",
"for item in list1:\n",
" list3 = []\n",
" name = item[3]\n",
" code = item[4]\n",
" if str(code) in dict3.keys() and name ==dict3[str(code)]['name']:\n",
" list3 = [code,name,dict3[str(code)]['sex'],dict3[str(code)]['unit']] \n",
" list2.append(list3)\n",
"\n",
"filename = 'data/天津石化问卷情况表(20231218).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list2:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename)\n",
"print('ok') "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9b469138-1da9-43ca-98e8-8dc6cb3916ce",
"metadata": {},
"outputs": [],
"source": []
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "85a03b00-9624-4ae9-aa6d-386798d457df", "id": "85a03b00-9624-4ae9-aa6d-386798d457df",