From 27e63ce4d98ce102cdd733191edf56571966d9ee Mon Sep 17 00:00:00 2001 From: 512song Date: Tue, 11 Apr 2023 17:51:31 +0800 Subject: [PATCH] 20230411 --- 体测单位/东营羊庙.ipynb | 145 +++++++++++++++++++++------------------- 1 file changed, 75 insertions(+), 70 deletions(-) diff --git a/体测单位/东营羊庙.ipynb b/体测单位/东营羊庙.ipynb index 334b63f..6928fed 100644 --- a/体测单位/东营羊庙.ipynb +++ b/体测单位/东营羊庙.ipynb @@ -1072,27 +1072,12 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": null, "id": "5d24953d-4ded-4e1c-911c-a0baab222399", "metadata": { - "execution": { - "iopub.execute_input": "2023-04-01T09:44:43.894749Z", - "iopub.status.busy": "2023-04-01T09:44:43.893902Z", - "iopub.status.idle": "2023-04-01T09:44:44.014089Z", - "shell.execute_reply": "2023-04-01T09:44:44.013281Z", - "shell.execute_reply.started": "2023-04-01T09:44:43.894709Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['437', '422', '417', '416', '415', '403', '399', '397', '393', '392', '389', '387', '382', '377', '376', '371', '365', '364', '362', '361', '357', '355', '353', '351', '349', '346', '345', '344', '340', '335', '333', '332', '330', '329', '328', '326', '323', '322', '317', '315', '314', '309', '306', '305', '294', '293', '291', '282', '281', '279', '278', '277', '276', '274', '273', '272', '271', '270', '265', '264', '262', '261', '259', '258', '256', '239', '236', '223', '221', '219', '214', '213', '212', '209', '208', '191', '188', '187', '186', '183', '179', '174', '172', '168', '167', '166', '164', '162', '160', '157', '156', '140', '139', '138', '137', '136', '135', '127', '124', '123', '122', '121', '116', '115', '111', '110', '106', '103', '100', '98', '97', '96', '95', '94', '89', '76', '74', '73', '58', '53', '52', '46', '42', '41', '40', '39', '35', '34', '30', '28', '26', '25', '23', '16', '13', '12', '11', '8', '6', '5']\n" - ] - } - ], + "outputs": [], "source": [ "import os,sys,shutil\n", "import json\n", @@ -1137,27 +1122,12 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": null, "id": "efa10ba4-0a27-41e6-beb7-27de8f3109a1", "metadata": { - "execution": { - "iopub.execute_input": "2023-04-01T09:40:25.949400Z", - "iopub.status.busy": "2023-04-01T09:40:25.948559Z", - "iopub.status.idle": "2023-04-01T09:40:26.009374Z", - "shell.execute_reply": "2023-04-01T09:40:26.008325Z", - "shell.execute_reply.started": "2023-04-01T09:40:25.949359Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['134', '147', '177', '181', '185', '193', '200', '201', '208', '213', '251', '263', '292', '320', '347', '358', '374', '383', '410', '435', '434', '437', '433', '155', '113', '108', '97', '92', '245', '71', '70', '69', '65', '64', '60', '58', '54', '32', '180', '217', '411', '414', '370', '381', '389', '270', '278', '192', '190', '196', '17', '13', '12', '11', '5', '4', '436', '121', '122', '124', '133', '137', '138', '141', '142', '143', '150', '157', '158', '160', '167', '115', '114', '111', '103', '96', '94', '93', '89', '87', '85', '83', '79', '77', '233', '234', '236', '74', '73', '59', '55', '53', '52', '49', '48', '47', '43', '42', '35', '34', '26', '23', '172', '171', '175', '186', '289', '290', '294', '310', '309', '316', '199', '202', '207', '209', '210', '211', '219', '222', '223', '229', '415', '6002', '346', '349', '357', '362', '363', '365', '369', '371', '373', '379', '376', '372', '378', '393', '400', '314', '324', '323', '328', '330', '332', '334', '343', '259', '267', '271', '273', '277', '276', '282', '345']\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import pymysql\n", @@ -1196,27 +1166,12 @@ }, { "cell_type": "code", - "execution_count": 69, + "execution_count": null, "id": "e5bd9e8c-00f5-48b7-8cc7-810316e0423b", "metadata": { - "execution": { - "iopub.execute_input": "2023-04-01T11:11:09.553748Z", - "iopub.status.busy": "2023-04-01T11:11:09.553341Z", - "iopub.status.idle": "2023-04-01T11:11:09.598656Z", - "shell.execute_reply": "2023-04-01T11:11:09.597753Z", - "shell.execute_reply.started": "2023-04-01T11:11:09.553720Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['107', '127', '134', '147', '146', '161', '177', '181', '185', '193', '200', '201', '208', '213', '251', '263', '292', '295', '313', '319', '320', '98765', '342', '360', '358', '359', '374', '6000', '6003', '423', '435', '434', '155', '156', '113', '108', '104', '245', '253', '71', '70', '69', '66', '65', '64', '63', '61', '58', '54', '46', '45', '32', '174', '180', '404', '411', '414', '427', '361', '381', '268', '266', '270', '417', '303', '192', '190', '194', '195', '196', '17', '16', '13', '12', '11', '9', '8', '7', '6', '5', '4', '436', '121', '122', '124', '123', '130', '126', '133', '136', '135', '137', '139', '140', '142', '143', '144', '151', '150', '157', '158', '159', '160', '166', '118', '117', '116', '115', '111', '110', '109', '103', '101', '98', '96', '95', '94', '89', '88', '87', '86', '83', '82', '80', '79', '77', '231', '237', '233', '234', '239', '236', '243', '244', '242', '256', '257', '258', '164', '163', '74', '75', '67', '59', '57', '56', '53', '52', '49', '48', '47', '43', '41', '40', '37', '36', '35', '34', '33', '31', '30', '26', '25', '24', '23', '172', '171', '175', '179', '183', '186', '187', '188', '289', '290', '293', '294', '296', '305', '308', '310', '309', '316', '203', '199', '202', '207', '214', '211', '219', '221', '222', '223', '229', '401', '399', '403', '406', '415', '6002', '430', '346', '349', '348', '353', '357', '355', '351', '362', '364', '365', '369', '368', '371', '373', '377', '379', '376', '372', '378', '382', '386', '393', '392', '396', '400', '314', '318', '323', '322', '326', '325', '328', '331', '330', '332', '334', '335', '337', '333', '344', '259', '262', '264', '260', '265', '267', '272', '271', '273', '275', '277', '276', '281', '283', '282', '286', '345']\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import pymysql\n", @@ -1247,28 +1202,12 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": null, "id": "4c02f3b9-6677-4114-9fd9-f9d8bccaefe0", "metadata": { - "execution": { - "iopub.execute_input": "2023-04-01T11:11:18.106136Z", - "iopub.status.busy": "2023-04-01T11:11:18.105295Z", - "iopub.status.idle": "2023-04-01T11:11:18.196768Z", - "shell.execute_reply": "2023-04-01T11:11:18.195822Z", - "shell.execute_reply.started": "2023-04-01T11:11:18.106095Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'高血压': ['437', '422', '417', '416', '415', '403', '399', '397', '393', '392', '389', '387', '382', '377', '376', '371', '365', '364', '362', '361', '357', '355', '353', '351', '349', '346', '345', '344', '340', '335', '333', '332', '330', '329', '328', '326', '323', '322', '317', '315', '314', '309', '306', '305', '294', '293', '291', '282', '281', '279', '278', '277', '276', '274', '273', '272', '271', '270', '265', '264', '262', '261', '259', '258', '256', '239', '236', '223', '221', '219', '214', '213', '212', '209', '208', '191', '188', '187', '186', '183', '179', '174', '172', '168', '167', '166', '164', '162', '160', '157', '156', '140', '139', '138', '137', '136', '135', '127', '124', '123', '122', '121', '116', '115', '111', '110', '106', '103', '100', '98', '97', '96', '95', '94', '89', '76', '74', '73', '58', '53', '52', '46', '42', '41', '40', '39', '35', '34', '30', '28', '26', '25', '23', '16', '13', '12', '11', '8', '6', '5'], '失眠': ['134', '147', '177', '181', '185', '193', '200', '201', '251', '263', '292', '320', '347', '358', '374', '383', '410', '435', '434', '433', '155', '113', '108', '92', '245', '71', '70', '69', '65', '64', '60', '54', '32', '180', '217', '411', '414', '370', '381', '192', '190', '196', '17', '4', '436', '133', '141', '142', '143', '150', '158', '114', '93', '87', '85', '83', '79', '77', '233', '234', '59', '55', '49', '48', '47', '43', '171', '175', '289', '290', '310', '316', '199', '202', '207', '210', '211', '222', '229', '6002', '363', '369', '373', '379', '372', '378', '400', '324', '334', '343', '267'], '脊柱调理': ['107', '146', '161', '295', '313', '319', '98765', '342', '360', '359', '6000', '6003', '423', '104', '253', '66', '63', '61', '45', '404', '427', '268', '266', '303', '194', '195', '9', '7', '130', '126', '144', '151', '159', '118', '117', '109', '101', '88', '86', '82', '80', '231', '237', '243', '244', '242', '257', '163', '75', '67', '57', '56', '37', '36', '33', '31', '24', '296', '308', '203', '401', '406', '430', '348', '368', '386', '396', '318', '325', '331', '337', '260', '275', '283', '286'], '整体调理': ['2', '3', '10', '15', '18', '22', '27', '29', '38', '44', '51', '62', '68', '72', '78', '81', '84', '90', '91', '99', '105', '112', '119', '120', '128', '129', '132', '145', '148', '149', '152', '153', '154', '165', '169', '170', '173', '176', '178', '184', '189', '197', '198', '204', '205', '206', '215', '216', '218', '220', '224', '225', '227', '228', '235', '238', '240', '241', '248', '249', '250', '255', '269', '284', '285', '287', '297', '301', '302', '307', '321', '327', '336', '352', '354', '356', '375', '391', '394', '395', '402', '405', '407', '408', '412', '418', '419', '420', '421', '424', '429', '431', '432', '6001', '98776']}\n", - "ok!\n" - ] - } - ], + "outputs": [], "source": [ "dict2 = {}\n", "dict2.setdefault('高血压',[])\n", @@ -1306,10 +1245,76 @@ " " ] }, + { + "cell_type": "markdown", + "id": "c7963b8e-91f4-4d26-81f1-93c1b3822efc", + "metadata": {}, + "source": [ + "# 杨庙社数据维护" + ] + }, + { + "cell_type": "markdown", + "id": "050db697-d8e1-4799-8f68-c8975a7ea4f2", + "metadata": {}, + "source": [ + "## 导入分组表" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "id": "09b893e1-0012-4610-aac0-9361685bdf37", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-11T09:41:50.755500Z", + "iopub.status.busy": "2023-04-11T09:41:50.754647Z", + "iopub.status.idle": "2023-04-11T09:41:50.936375Z", + "shell.execute_reply": "2023-04-11T09:41:50.935566Z", + "shell.execute_reply.started": "2023-04-11T09:41:50.755459Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "import psycopg2\n", + "from psycopg2 import extras as ex\n", + "import openpyxl\n", + "\n", + "wb = openpyxl.load_workbook('data/杨庙社区分组情况表.xlsx')\n", + "sheet = wb.active\n", + "data_list = []\n", + "for n in range(2, sheet.max_row+1):\n", + " code = int(sheet.cell(n, 3).value)\n", + " name = sheet.cell(n, 4).value\n", + " birth = str(sheet.cell(n, 5).value).split(' ')[0]\n", + " unit = sheet.cell(n, 6).value \n", + " category = sheet.cell(n, 2).value \n", + " if sheet.cell(n, 7).value is not None:\n", + " phone = str(sheet.cell(n, 7).value)\n", + " else:\n", + " phone = ''\n", + " xb = int(sheet.cell(n, 8).value)\n", + " if xb ==1:\n", + " sex = '男'\n", + " else:\n", + " sex = '女'\n", + " data_list.append((code,name,sex,birth,category,unit,phone))\n", + "#print(data_list)\n", + "\n", + "conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n", + "cursor = conn.cursor()\n", + "sql = 'insert into yangmiao_fenzu (code,name,sex,birth,category,unit,phone) values %s'\n", + "ex.execute_values(cursor, sql, data_list, page_size=10000)\n", + "conn.commit()\n", + "cursor.close()\n", + "conn.close()" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "0077bd98-5a26-4543-a262-c66f419b6db3", + "id": "87e18625-a371-4a3c-94d2-69c2a9ac6c48", "metadata": {}, "outputs": [], "source": []