20211014
导出单位人员信息
This commit is contained in:
1 parent
4ccfcaadcc
commit
7799058124
1 file changed
+77
-15
+77
-15
@@ -114,12 +114,27 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 9,
|
||||
"id": "d80c482d-aee2-45cf-8ac8-c357171f17f7",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2021-10-14T02:37:23.916203Z",
|
||||
"iopub.status.busy": "2021-10-14T02:37:23.915266Z",
|
||||
"iopub.status.idle": "2021-10-14T02:37:27.064162Z",
|
||||
"shell.execute_reply": "2021-10-14T02:37:27.062406Z",
|
||||
"shell.execute_reply.started": "2021-10-14T02:37:23.916098Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
@@ -128,14 +143,61 @@
|
||||
"\n",
|
||||
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
||||
"mydb = myclient[\"tice\"]\n",
|
||||
"mycol = mydb[\"unit\"]\n",
|
||||
"mycol = mydb[\"person\"]\n",
|
||||
"\n",
|
||||
"myquery = { \"_id\": ObjectId(\"6164fc343d39c8cdd2d97179\")}\n",
|
||||
" \n",
|
||||
"mydoc = mycol.find(myquery)\n",
|
||||
" \n",
|
||||
"for x in mydoc:\n",
|
||||
" print(x)"
|
||||
"wb = openpyxl.load_workbook('data/中国石油化工股份有限公司安庆炼化分公司员工在职人员名单.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"#sheets = wb.sheetnames\n",
|
||||
"list1 = []\n",
|
||||
"person = {}\n",
|
||||
"new_code = []\n",
|
||||
"for n in range(2,sheet.max_row+1):\n",
|
||||
" code = 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",
|
||||
" dict1['unit'] = sheet.cell(n,5).value\n",
|
||||
" if sheet.cell(n,4).value is None:\n",
|
||||
" dict1['birth'] = sheet.cell(n,6).value\n",
|
||||
" else:\n",
|
||||
" dict1['id_num'] = sheet.cell(n,4).value\n",
|
||||
" person[code] = dict1\n",
|
||||
"filename = '安庆炼化人员名单.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(person, fl,ensure_ascii=False) \n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"id": "adf13de2-8205-4511-a655-75989440967e",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2021-10-14T02:37:55.876237Z",
|
||||
"iopub.status.busy": "2021-10-14T02:37:55.875300Z",
|
||||
"iopub.status.idle": "2021-10-14T02:37:55.956149Z",
|
||||
"shell.execute_reply": "2021-10-14T02:37:55.953871Z",
|
||||
"shell.execute_reply.started": "2021-10-14T02:37:55.876131Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{'00001': {'name': '汪东球', 'sex': '男', 'unit': '办公室', 'id_num': '340803196511112679'}, '00002': {'name': '华传伦', 'sex': '男', 'unit': '办公室', 'id_num': '340803196409212673'}, '00003': {'name': '徐乐', 'sex': '男', 'unit': '办公室', 'id_num': '340803198007292235'}, '00004': {'name': '汪向东', 'sex': '男', 'unit': '办公室', 'id_num': '620104196907150538'}, '00005': {'name': '包永', 'sex': '男', 'unit': '办公室', 'id_num': '370102197706143753'}, '00006': {'name': '黄晓华', 'sex': '男', 'unit': '办公室', 'id_num': '340803196310022693'}, '00007': {'name': '刘晓华', 'sex': '男', 'unit': '办公室', 'id_num': '340803196509112776'}, '00008': {'name': '成雷', 'sex': '男', 'unit': '办公室', 'id_num': '340803196303062697'}, '00009': {'name': '周琼', 'sex': '女', 'unit': '办公室', 'id_num': '340202197301150023'}, '00010': {'name': '张业金', 'sex': '男', 'unit': '办公室', 'id_num': '110105196501045451'}, '00011': {'name': '宫超', 'sex': '男', 'unit': '办公室', 'id_num': '340803196908042672'}, '00012': {'name': '周小龙', 'sex': '男', 'unit': '办公室', 'id_num': '362202197505135015'}, '00013': {'name': '关广磊', 'sex': '男', 'unit': '办公室', 'id_num': '340421198808294813'}, '00014': {'name': '何健健', 'sex': '女', 'unit': '办公室', 'id_num': '340803196708042766'}, '00015': {'name': '李险峰', 'sex': '男', 'unit': '办公室', 'id_num': '342401199003138515'}, '00016': {'name': '佘才慧', 'sex': '女', 'unit': '办公室', 'id_num': '340803197207062667'}, '00017': {'name': '张莉', 'sex': '女', 'unit': '办公室', 'id_num': '340803197305242223'}, '00018': {'name': '高智红', 'sex': '女', 'unit': '办公室', 'id_num': '340803197401012700'}, '00019': {'name': '吴伟', 'sex': '男', 'unit': '办公室', 'id_num': '340803197710252775'}, '00020': {'name': '夏锐', 'sex': '男', 'unit': '办公室', 'id_num': '340803196511022673'}, '00021': {'name': '刘军', 'sex': '男', 'unit': '办公室', 'id_num': '340802196710300019'}, '00022': {'name': '刘丹', 'sex': '女', 'unit': '办公室', 'id_num': '340822198810202648'}, '00023': {'name': '夏来福', 'sex': '男', 'unit': '办公室', 'id_num': '340803197206022970'}, '00024': {'name': '陈倞', 'sex': '男', 'unit': '办公室', 'id_num': '340803197206082316'}, '00025': {'name': '谢琼', 'sex': '女', 'unit': '办公室', 'id_num': '340803196803122668'}, '00026': {'name': '周继红', 'sex': '女', 'unit': '办公室', 'id_num': '340823196706010029'}, '00027': {'name': '潘涛', 'sex': '男', 'unit': '办公室', 'id_num': '340803196812312033'}, '00028': {'name': '张胜利', 'sex': '男', 'unit': '办公室', 'id_num': '340803196909162676'}, '00029': {'name': '单军', 'sex': '男', 'unit': '办公室', 'id_num': '340803196404152413'}, '00030': {'name': '陈刚', 'sex': '男', 'unit': '办公室', 'id_num': '340803196712292776'}, '00031': {'name': '王斌', 'sex': '男', 'unit': '办公室', 'id_num': '340802196802070230'}, '00032': {'name': '王宇', 'sex': '男', 'unit': '办公室', 'id_num': '340803196501272679'}, '00033': {'name': '王剑', 'sex': '男', 'unit': '办公室', 'id_num': '34080219650403061X'}, '00034': {'name': '王官成', 'sex': '男', 'unit': '办公室', 'id_num': '340803196207032770'}, '00035': {'name': '杨健', 'sex': '男', 'unit': '办公室', 'id_num': '340803196901022417'}, '00036': {'name': '姚振辉', 'sex': '男', 'unit': '办公室', 'id_num': '340803196306032434'}, '00037': {'name': '邹丹军', 'sex': '男', 'unit': '办公室', 'id_num': '340803196901302670'}, '00038': {'name': '赵军', 'sex': '男', 'unit': '办公室', 'id_num': '340803196708032517'}, '00039': {'name': '江启任', 'sex': '男', 'unit': '办公室', 'id_num': '34080319630419267X'}, '00040': {'name': '陈宏伟', 'sex': '男', 'unit': '办公室', 'id_num': '340803196306292674'}, '00041': {'name': '汪斌', 'sex': '男', 'unit': '办公室', 'id_num': '340803196904242677'}, '00042': {'name': '朱金才', 'sex': '男', 'unit': '办公室', 'id_num': '340803196508072792'}, '00043': {'name': '汪涛', 'sex': '男', 'unit': '办公室', 'id_num': '340803196411062678'}, '00044': {'name': '孙小宁', 'sex': '男', 'unit': '办公室', 'id_num': '340802196408150419'}, '00045': {'name': '武飞', 'sex': '男', 'unit': '办公室', 'id_num': '340803196308122679'}, '00046': {'name': '刘波', 'sex': '男', 'unit': '办公室', 'id_num': '340803196604252873'}, '00047': {'name': '张文生', 'sex': '男', 'unit': '办公室', 'id_num': '340803196812252691'}, '00048': {'name': '潘刚', 'sex': '男', 'unit': '办公室', 'id_num': '340802196209170636'}, '00049': {'name': '赵晓春', 'sex': '男', 'unit': '办公室', 'id_num': '340803196404122214'}, '00050': {'name': '王自昆', 'sex': '男', 'unit': '办公室', 'id_num': '340803196503262677'}, '00051': {'name': '杨雷', 'sex': '男', 'unit': '办公室', 'id_num': '340803197007122696'}, '00052': {'name': 'Line truncated
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"filename = '安庆炼化人员名单.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" list1 = json.load(fl) \n",
|
||||
"print(list1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -148,15 +210,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 95,
|
||||
"execution_count": 1,
|
||||
"id": "910c3fcd-121a-42c0-9465-ad79a5829239",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2021-10-12T14:56:11.707898Z",
|
||||
"iopub.status.busy": "2021-10-12T14:56:11.706965Z",
|
||||
"iopub.status.idle": "2021-10-12T14:56:11.819192Z",
|
||||
"shell.execute_reply": "2021-10-12T14:56:11.816891Z",
|
||||
"shell.execute_reply.started": "2021-10-12T14:56:11.707790Z"
|
||||
"iopub.execute_input": "2021-10-13T07:09:10.932437Z",
|
||||
"iopub.status.busy": "2021-10-13T07:09:10.931304Z",
|
||||
"iopub.status.idle": "2021-10-13T07:09:11.647770Z",
|
||||
"shell.execute_reply": "2021-10-13T07:09:11.644666Z",
|
||||
"shell.execute_reply.started": "2021-10-13T07:09:10.932172Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user