20250223
This commit is contained in:
1 parent
adfaa3c638
commit
82acaa07a8
2 files changed
+468
-30
No files matched your search
+28
-28
@@ -10,15 +10,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 8,
|
"execution_count": 1,
|
||||||
"id": "3d5ddc7a-a331-438d-aa8d-1ad74c7250d0",
|
"id": "3d5ddc7a-a331-438d-aa8d-1ad74c7250d0",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-02-16T15:21:01.891534Z",
|
"iopub.execute_input": "2025-02-23T10:13:29.334391Z",
|
||||||
"iopub.status.busy": "2025-02-16T15:21:01.890870Z",
|
"iopub.status.busy": "2025-02-23T10:13:29.333636Z",
|
||||||
"iopub.status.idle": "2025-02-16T15:21:01.912369Z",
|
"iopub.status.idle": "2025-02-23T10:13:29.512654Z",
|
||||||
"shell.execute_reply": "2025-02-16T15:21:01.911830Z",
|
"shell.execute_reply": "2025-02-23T10:13:29.511636Z",
|
||||||
"shell.execute_reply.started": "2025-02-16T15:21:01.891472Z"
|
"shell.execute_reply.started": "2025-02-23T10:13:29.334322Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -65,15 +65,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 9,
|
"execution_count": 2,
|
||||||
"id": "72ec680f-ec0d-44f9-919c-17c8e614b885",
|
"id": "72ec680f-ec0d-44f9-919c-17c8e614b885",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-02-16T15:25:46.643327Z",
|
"iopub.execute_input": "2025-02-23T10:13:35.977412Z",
|
||||||
"iopub.status.busy": "2025-02-16T15:25:46.642655Z",
|
"iopub.status.busy": "2025-02-23T10:13:35.976513Z",
|
||||||
"iopub.status.idle": "2025-02-16T15:25:46.658469Z",
|
"iopub.status.idle": "2025-02-23T10:13:35.998305Z",
|
||||||
"shell.execute_reply": "2025-02-16T15:25:46.657469Z",
|
"shell.execute_reply": "2025-02-23T10:13:35.997869Z",
|
||||||
"shell.execute_reply.started": "2025-02-16T15:25:46.643266Z"
|
"shell.execute_reply.started": "2025-02-23T10:13:35.977335Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"28\n"
|
"113\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -98,7 +98,7 @@
|
|||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
" dict1 = json.load(fl) \n",
|
" dict1 = json.load(fl) \n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/marks_20250216.csv'\n",
|
"filename = 'data/marks_20250223.csv'\n",
|
||||||
"with open(filename,'r',newline='') as csv_file:\n",
|
"with open(filename,'r',newline='') as csv_file:\n",
|
||||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||||
" header = next(fl) \n",
|
" header = next(fl) \n",
|
||||||
@@ -149,15 +149,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 10,
|
"execution_count": 3,
|
||||||
"id": "8f459ed3-fc14-404f-998b-5ed2a15958c3",
|
"id": "8f459ed3-fc14-404f-998b-5ed2a15958c3",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-02-16T15:26:06.721842Z",
|
"iopub.execute_input": "2025-02-23T10:13:40.888693Z",
|
||||||
"iopub.status.busy": "2025-02-16T15:26:06.721214Z",
|
"iopub.status.busy": "2025-02-23T10:13:40.887898Z",
|
||||||
"iopub.status.idle": "2025-02-16T15:26:06.738331Z",
|
"iopub.status.idle": "2025-02-23T10:13:40.910971Z",
|
||||||
"shell.execute_reply": "2025-02-16T15:26:06.737149Z",
|
"shell.execute_reply": "2025-02-23T10:13:40.910112Z",
|
||||||
"shell.execute_reply.started": "2025-02-16T15:26:06.721782Z"
|
"shell.execute_reply.started": "2025-02-23T10:13:40.888581Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -370,15 +370,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 14,
|
"execution_count": 5,
|
||||||
"id": "f44c57ed-aac8-481a-9126-0dadcbe0190c",
|
"id": "f44c57ed-aac8-481a-9126-0dadcbe0190c",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2025-02-16T15:36:05.627841Z",
|
"iopub.execute_input": "2025-02-23T10:14:06.379557Z",
|
||||||
"iopub.status.busy": "2025-02-16T15:36:05.627122Z",
|
"iopub.status.busy": "2025-02-23T10:14:06.379298Z",
|
||||||
"iopub.status.idle": "2025-02-16T15:36:05.655606Z",
|
"iopub.status.idle": "2025-02-23T10:14:06.424726Z",
|
||||||
"shell.execute_reply": "2025-02-16T15:36:05.655044Z",
|
"shell.execute_reply": "2025-02-23T10:14:06.424184Z",
|
||||||
"shell.execute_reply.started": "2025-02-16T15:36:05.627774Z"
|
"shell.execute_reply.started": "2025-02-23T10:14:06.379536Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -396,7 +396,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
|
"items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
|
||||||
"bmi = ['height','weight']\n",
|
"bmi = ['height','weight']\n",
|
||||||
"title = ['编号','姓名','性别','身高','体重','bmi','肺活量','得分','握力','','坐位体前屈','','纵跳','','俯卧撑','','一分钟仰卧起坐','','单脚站立','','选择反应时','','台阶指数']\n",
|
"title = ['编号','姓名','性别','身高','体重','bmi','肺活量','得分','握力','得分','坐位体前屈','得分','纵跳','得分','俯卧撑','得分','一分钟仰卧起坐','得分','单脚站立','得分','选择反应时','得分','台阶指数','得分']\n",
|
||||||
"\n",
|
"\n",
|
||||||
"filename = 'data/result_延庆人员.json'\n",
|
"filename = 'data/result_延庆人员.json'\n",
|
||||||
"with open(filename,'r') as fl:\n",
|
"with open(filename,'r') as fl:\n",
|
||||||
@@ -432,7 +432,7 @@
|
|||||||
" list2.append('') \n",
|
" list2.append('') \n",
|
||||||
" if i>2:\n",
|
" if i>2:\n",
|
||||||
" list1.append(list2)\n",
|
" list1.append(list2)\n",
|
||||||
"filename = 'data/延庆体测情况表250216.xlsx'\n",
|
"filename = 'data/延庆体测情况表250223.xlsx'\n",
|
||||||
"wb = openpyxl.Workbook()\n",
|
"wb = openpyxl.Workbook()\n",
|
||||||
"sheet = wb.active\n",
|
"sheet = wb.active\n",
|
||||||
"sheet.append(title)\n",
|
"sheet.append(title)\n",
|
||||||
|
|||||||
+440
-2
@@ -3,7 +3,9 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "511a2aee-e09b-475a-a201-f6e1c72e053b",
|
"id": "511a2aee-e09b-475a-a201-f6e1c72e053b",
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"jp-MarkdownHeadingCollapsed": true
|
||||||
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"# 体测数据处理"
|
"# 体测数据处理"
|
||||||
]
|
]
|
||||||
@@ -1282,8 +1284,444 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "1208eb16-a220-48c4-8c9e-cc4dbf67306e",
|
"id": "8feaa7bb-92dd-44ab-9869-c601d468b4b8",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# 体测数据处理(2025年)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "54ed5a3c-ba4d-463f-83f7-3c621142f7bb",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 体测人员导入"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 23,
|
||||||
|
"id": "80a24c3c-8f7d-4c02-a5ee-3daa438ca35b",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-01-20T01:27:26.442760Z",
|
||||||
|
"iopub.status.busy": "2025-01-20T01:27:26.442000Z",
|
||||||
|
"iopub.status.idle": "2025-01-20T01:27:26.468889Z",
|
||||||
|
"shell.execute_reply": "2025-01-20T01:27:26.468324Z",
|
||||||
|
"shell.execute_reply.started": "2025-01-20T01:27:26.442687Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"81 ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"wb = openpyxl.load_workbook('data/青海2025.xlsx')\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"# sheets = wb.sheetnames\n",
|
||||||
|
"person = {}\n",
|
||||||
|
"\n",
|
||||||
|
"for n in range(2, sheet.max_row+1):\n",
|
||||||
|
" if sheet.cell(n, 1).value is not None:\n",
|
||||||
|
" #print(sheet.cell(n, 1).value)\n",
|
||||||
|
" code = int(sheet.cell(n, 1).value)\n",
|
||||||
|
" person.setdefault(code, {})\n",
|
||||||
|
" dict1 = {}\n",
|
||||||
|
" dict1['name'] = sheet.cell(n, 3).value\n",
|
||||||
|
" dict1['sex'] = sheet.cell(n, 4).value\n",
|
||||||
|
" dict1['unit'] = sheet.cell(n, 2).value\n",
|
||||||
|
" dict1['phone'] = int(sheet.cell(n, 6).value)\n",
|
||||||
|
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0]\n",
|
||||||
|
" person[code] = dict1\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/青海人员2025.json'\n",
|
||||||
|
"with open(filename, 'w') as fl:\n",
|
||||||
|
" json.dump(person, fl, ensure_ascii=False)\n",
|
||||||
|
"print(len(person),'ok')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "90ce631b-0eeb-4d27-965a-7efa09332139",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 获取人员测试成绩"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 16,
|
||||||
|
"id": "905dbd60-ef28-4bf4-85a2-5b2e6543dcfe",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-01-20T01:12:15.444982Z",
|
||||||
|
"iopub.status.busy": "2025-01-20T01:12:15.444234Z",
|
||||||
|
"iopub.status.idle": "2025-01-20T01:12:15.461283Z",
|
||||||
|
"shell.execute_reply": "2025-01-20T01:12:15.460768Z",
|
||||||
|
"shell.execute_reply.started": "2025-01-20T01:12:15.444909Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"72\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import datetime\n",
|
||||||
|
"import csv\n",
|
||||||
|
"from datetime import date\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"re_ta = {}\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"filename = 'data/青海人员2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl) \n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/marks_20250118.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",
|
||||||
|
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
||||||
|
" list1.append(line)\n",
|
||||||
|
"\n",
|
||||||
|
"for result in list1:\n",
|
||||||
|
" user = str(result[2])\n",
|
||||||
|
" rq = date.fromisoformat(result[5].replace('/','-'))\n",
|
||||||
|
" if user in dict1.keys():\n",
|
||||||
|
" l_xm = []\n",
|
||||||
|
" m_item = str(result[3]) \n",
|
||||||
|
" re_ta.setdefault(user,{}) \n",
|
||||||
|
" re_ta[user]['name'] = dict1[user]['name']\n",
|
||||||
|
" re_ta[user]['sex'] = dict1[user]['sex']\n",
|
||||||
|
" if 'phone' in dict1[user].keys():\n",
|
||||||
|
" re_ta[user]['phone'] = dict1[user]['phone']\n",
|
||||||
|
" if dict1[user]['sex'] == '男':\n",
|
||||||
|
" l_xm = ['bmi','lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
|
||||||
|
" else:\n",
|
||||||
|
" l_xm = ['bmi','lung','grip','flexion','jump','balance','reaction','step','situp']\n",
|
||||||
|
" re_ta[user]['unit'] = dict1[user]['unit']\n",
|
||||||
|
" birth = date.fromisoformat(dict1[user]['birth'].replace('/','-'))\n",
|
||||||
|
" item_name = result[3] \n",
|
||||||
|
" if item_name in l_xm: \n",
|
||||||
|
" days = (rq-birth).days \n",
|
||||||
|
" re_ta[user]['age'] = int(days/365)\n",
|
||||||
|
" re_ta[user]['month'] = int(days/365*12)\n",
|
||||||
|
" re_ta[user]['rq'] = result[5]\n",
|
||||||
|
" re_ta[user].setdefault(item_name,{}) \n",
|
||||||
|
" score = result[4] \n",
|
||||||
|
" re_ta[user][item_name]['成绩'] = score\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_青海2025.json'\n",
|
||||||
|
"with open(filename,'w') as fl:\n",
|
||||||
|
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||||
|
"print(len(re_ta))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "c6ede59a-e5a0-489b-853f-f317e12b1fa3",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 导出测试人员信息"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 17,
|
||||||
|
"id": "f3d39079-fa3a-400c-990e-75a8a0a7b42d",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-01-20T01:12:49.821141Z",
|
||||||
|
"iopub.status.busy": "2025-01-20T01:12:49.820394Z",
|
||||||
|
"iopub.status.idle": "2025-01-20T01:12:49.854877Z",
|
||||||
|
"shell.execute_reply": "2025-01-20T01:12:49.854327Z",
|
||||||
|
"shell.execute_reply.started": "2025-01-20T01:12:49.821069Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
|
||||||
|
"title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_青海2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/青海人员2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
" \n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" list2 = []\n",
|
||||||
|
" list2.append(str(k).rjust(5,'0'))\n",
|
||||||
|
" list2.append(v['name']) \n",
|
||||||
|
" list2.append(dict2[k]['sex'])\n",
|
||||||
|
" list2.append(dict2[k]['unit'])\n",
|
||||||
|
" if 'bmi' in v.keys():\n",
|
||||||
|
" height = v['bmi']['成绩'].split(',')[0]\n",
|
||||||
|
" weight = v['bmi']['成绩'].split(',')[1]\n",
|
||||||
|
" list2.append(height)\n",
|
||||||
|
" list2.append(weight)\n",
|
||||||
|
" else:\n",
|
||||||
|
" list2.append('')\n",
|
||||||
|
" list2.append('')\n",
|
||||||
|
" for item in items:\n",
|
||||||
|
" if item in v.keys():\n",
|
||||||
|
" list2.append(v[item]['成绩']) \n",
|
||||||
|
" elif item =='name':\n",
|
||||||
|
" list2.append(v[item])\n",
|
||||||
|
" else:\n",
|
||||||
|
" list2.append('')\n",
|
||||||
|
" \n",
|
||||||
|
" list1.append(list2)\n",
|
||||||
|
"filename = 'data/青海体测情况表2025.xlsx'\n",
|
||||||
|
"wb = openpyxl.Workbook()\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"sheet.append(title)\n",
|
||||||
|
"for row in list1:\n",
|
||||||
|
" sheet.append(row)\n",
|
||||||
|
" \n",
|
||||||
|
"wb.save(filename)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "a19c9733-7af5-4dc6-a0ca-cc35069f532a",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 统计参加问卷人员"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 25,
|
||||||
|
"id": "f0ee678a-1dd1-4928-a198-df0ff5142f89",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-01-20T01:27:43.425720Z",
|
||||||
|
"iopub.status.busy": "2025-01-20T01:27:43.425142Z",
|
||||||
|
"iopub.status.idle": "2025-01-20T01:27:43.449977Z",
|
||||||
|
"shell.execute_reply": "2025-01-20T01:27:43.449445Z",
|
||||||
|
"shell.execute_reply.started": "2025-01-20T01:27:43.425664Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"80\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import csv\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import time\n",
|
||||||
|
"from datetime import date\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/青海人员2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"phone1 = set()\n",
|
||||||
|
"phone2 = set()\n",
|
||||||
|
"for k,v in dict1.items():\n",
|
||||||
|
" phone1.add(v['phone'])\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"filename = 'data/Survey_20250118.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",
|
||||||
|
"print(len(phone1))\n",
|
||||||
|
"i =1\n",
|
||||||
|
"list2 = []\n",
|
||||||
|
"for item in list1:\n",
|
||||||
|
" code = int(item[2])\n",
|
||||||
|
" for k, v in dict1.items():\n",
|
||||||
|
" list3 = []\n",
|
||||||
|
" if v['phone'] == code: \n",
|
||||||
|
" list3.append(k)\n",
|
||||||
|
" list3.append(v['name'])\n",
|
||||||
|
" list3.append(v['sex'])\n",
|
||||||
|
" list3.append(v['unit'])\n",
|
||||||
|
" list3.append(code)\n",
|
||||||
|
" list2.append(list3)\n",
|
||||||
|
"filename = 'data/青海问卷情况表2025.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) "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "19aaf610-b15d-45c8-b22e-c56e9b8d8450",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 统计问卷人员手机号码未登记"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 24,
|
||||||
|
"id": "00eb991d-771f-4ff4-af9f-35a0d3b64581",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-01-20T01:27:34.074005Z",
|
||||||
|
"iopub.status.busy": "2025-01-20T01:27:34.073295Z",
|
||||||
|
"iopub.status.idle": "2025-01-20T01:27:34.085198Z",
|
||||||
|
"shell.execute_reply": "2025-01-20T01:27:34.084107Z",
|
||||||
|
"shell.execute_reply.started": "2025-01-20T01:27:34.073939Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"80\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import csv\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import time\n",
|
||||||
|
"from datetime import date\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/青海人员2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"phone1 = set()\n",
|
||||||
|
"phone2 = set()\n",
|
||||||
|
"for k,v in dict1.items():\n",
|
||||||
|
" phone1.add(v['phone'])\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"filename = 'data/Survey_20250118.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",
|
||||||
|
"print(len(phone1))\n",
|
||||||
|
"i =1\n",
|
||||||
|
"list2 = []\n",
|
||||||
|
"for item in list1:\n",
|
||||||
|
" code = int(item[2])\n",
|
||||||
|
" if code not in phone1:\n",
|
||||||
|
" content = json.loads(item[5])\n",
|
||||||
|
" if 'name' in content.keys():\n",
|
||||||
|
" print(code,content['name'])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "9cabe52a-2862-4ba8-847f-d685df1060cd",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 统计未参加问卷人员"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 6,
|
||||||
|
"id": "d91e74d4-22f0-4db2-bad4-717f7537c043",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2025-01-22T05:32:09.347446Z",
|
||||||
|
"iopub.status.busy": "2025-01-22T05:32:09.346691Z",
|
||||||
|
"iopub.status.idle": "2025-01-22T05:32:09.373252Z",
|
||||||
|
"shell.execute_reply": "2025-01-22T05:32:09.372574Z",
|
||||||
|
"shell.execute_reply.started": "2025-01-22T05:32:09.347377Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"45\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import csv\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import time\n",
|
||||||
|
"from datetime import date\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/青海人员2025.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"phone1 = set()\n",
|
||||||
|
"phone2 = set()\n",
|
||||||
|
"for k,v in dict1.items():\n",
|
||||||
|
" phone1.add(v['phone'])\n",
|
||||||
|
"list1 = []\n",
|
||||||
|
"filename = 'data/Survey_20250118.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",
|
||||||
|
" phone2.add(int(line[2]))\n",
|
||||||
|
"print(len(phone2))\n",
|
||||||
|
"i =1\n",
|
||||||
|
"\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" if v['phone'] not in phone2:\n",
|
||||||
|
" list2 = []\n",
|
||||||
|
" list2 = [k,v['name'],v['sex'],v['phone']]\n",
|
||||||
|
" list1.append(list2)\n",
|
||||||
|
"filename = 'data/青海未参加问卷人员2025.xlsx'\n",
|
||||||
|
"wb = openpyxl.Workbook()\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"#sheet.append(title)\n",
|
||||||
|
"for row in list1:\n",
|
||||||
|
" sheet.append(row)\n",
|
||||||
|
" \n",
|
||||||
|
"wb.save(filename) "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "1208eb16-a220-48c4-8c9e-cc4dbf67306e",
|
||||||
|
"metadata": {
|
||||||
|
"jp-MarkdownHeadingCollapsed": true
|
||||||
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"# 体测数据分析"
|
"# 体测数据分析"
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in new issue
Block a user