20220430
This commit is contained in:
1 parent
a0f03188e3
commit
c7c2fb4208
3 files changed
+154
-419
No files matched your search
+150
-24
@@ -13,7 +13,9 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2a85feec-695b-4ea8-8093-91a59ed34c7f",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"toc-hr-collapsed": true
|
||||
},
|
||||
"source": [
|
||||
"## 体测单位信息导入"
|
||||
]
|
||||
@@ -386,26 +388,10 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": null,
|
||||
"id": "bae91469-c894-468a-9bdd-b1aae367ea39",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2022-04-27T07:46:25.321260Z",
|
||||
"iopub.status.busy": "2022-04-27T07:46:25.319843Z",
|
||||
"iopub.status.idle": "2022-04-27T07:46:30.328749Z",
|
||||
"shell.execute_reply": "2022-04-27T07:46:30.325499Z",
|
||||
"shell.execute_reply.started": "2022-04-27T07:46:25.320997Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
@@ -443,7 +429,9 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "bf42e8af-a506-4e60-a661-b4281e3fef54",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"toc-hr-collapsed": true
|
||||
},
|
||||
"source": [
|
||||
"## 录入体测信息"
|
||||
]
|
||||
@@ -627,7 +615,6 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "edc06db7-9ae5-441a-8273-88ad598096ba",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
@@ -918,7 +905,7 @@
|
||||
"for k,v in dict1.items():\n",
|
||||
" item[k] = v\n",
|
||||
"user_id = 5\n",
|
||||
"place_id =122\n",
|
||||
"place_id =128\n",
|
||||
"#user = '包永'\n",
|
||||
"db = pymysql.connect(\"localhost\",\"root\",\"songyi\",\"ydyb\" )\n",
|
||||
"cursor = db.cursor()\n",
|
||||
@@ -947,12 +934,151 @@
|
||||
" \n",
|
||||
" #re_ta[user] = dict1\n",
|
||||
" #print(re_ta)\n",
|
||||
"filename = 'data/result_jn.json'\n",
|
||||
"filename = 'data/result_cl.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(re_ta, fl,ensure_ascii=False) \n",
|
||||
"print('ok')\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "95df2637-7898-4446-bb8a-70d881bd9e44",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 根据excel表转换测试成绩"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "5d214e99-b3eb-4079-97b5-a9da12b06e89",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = 'item.json'\n",
|
||||
"item = {}\n",
|
||||
"unit = {}\n",
|
||||
"\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"for v in dict1.values():\n",
|
||||
" #item[k] = v\n",
|
||||
" item[v['name']] = v['divisor']\n",
|
||||
" #print(v['divisor'])\n",
|
||||
"\n",
|
||||
"filename = 'data/长岭全成绩.xlsx'\n",
|
||||
"wb = openpyxl.load_workbook(filename)\n",
|
||||
"sheet = wb.active\n",
|
||||
"\n",
|
||||
"dict1 = {}\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" bh = sheet.cell(n, 1).value\n",
|
||||
" #print(bh)\n",
|
||||
" dict1.setdefault(bh, {})\n",
|
||||
" dict2 = {}\n",
|
||||
" dict1[bh]['bm'] = sheet.cell(n, 2).value\n",
|
||||
" dict1[bh]['name'] = sheet.cell(n, 3).value\n",
|
||||
" #dict2 = {}\n",
|
||||
" m_xm = sheet.cell(n, 4).value\n",
|
||||
" list1 = []\n",
|
||||
" \n",
|
||||
" list1.append(sheet.cell(n, 5).value/ item[sheet.cell(n, 4).value]) \n",
|
||||
" list1.append(sheet.cell(n, 6).value)\n",
|
||||
" dict1[bh][m_xm] = list1\n",
|
||||
"wb.close()\n",
|
||||
"filename = 'data/result_cl.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict1, fl,ensure_ascii=False) \n",
|
||||
"print('ok')\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 80,
|
||||
"id": "a7cf5e57-a381-4911-96ff-1e1469b6f9bc",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2022-04-30T13:33:40.348110Z",
|
||||
"iopub.status.busy": "2022-04-30T13:33:40.346875Z",
|
||||
"iopub.status.idle": "2022-04-30T13:33:44.806237Z",
|
||||
"shell.execute_reply": "2022-04-30T13:33:44.804223Z",
|
||||
"shell.execute_reply.started": "2022-04-30T13:33:40.347998Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"filename = 'data/result_cl.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = []\n",
|
||||
"for item in dict1.values():\n",
|
||||
" for k in item.keys():\n",
|
||||
" list1.append(k)\n",
|
||||
"list2 = set(list1)\n",
|
||||
"list2.remove('name')\n",
|
||||
"list2.remove('bm')\n",
|
||||
"list2.remove('身高')\n",
|
||||
"list2.remove('体重')\n",
|
||||
"#print(list2)\n",
|
||||
"\n",
|
||||
"col = {}\n",
|
||||
"col1 = {}\n",
|
||||
"\n",
|
||||
"s ='GHIJKLMNOPQRSTUVWXYZ'\n",
|
||||
"n = 0\n",
|
||||
"for item in list2:\n",
|
||||
" col[item] = s[n]\n",
|
||||
" col1[item] = s[n+1]\n",
|
||||
" n += 2\n",
|
||||
"#print(col)\n",
|
||||
"filename = 'data/长岭体检人员得分情况表.xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"sheet['A1'] = '测试编号'\n",
|
||||
"sheet['B1'] = '部门名称'\n",
|
||||
"sheet['C1'] = '姓名'\n",
|
||||
"sheet['D1'] = '身高'\n",
|
||||
"sheet['E1'] = '体重'\n",
|
||||
"sheet['F1'] = 'BMI'\n",
|
||||
"for k, v in col.items():\n",
|
||||
" sheet[f'{v}1'] = k\n",
|
||||
" #sheet[f'{v[1]}1'] = '得分'\n",
|
||||
"n = 2\n",
|
||||
"for k,v in dict1.items():\n",
|
||||
" #sheet[f'A{n}'] = n-1 \n",
|
||||
" #print(k,v)\n",
|
||||
" sheet[f'A{n}'] = k\n",
|
||||
" sheet[f'B{n}'] = v['bm']\n",
|
||||
" sheet[f'C{n}'] = v['name']\n",
|
||||
" if '身高' in v.keys():\n",
|
||||
" sheet[f'D{n}'] = v['身高'][0]\n",
|
||||
" if '体重' in v.keys():\n",
|
||||
" sheet[f'E{n}'] = v['体重'][0]\n",
|
||||
" sheet[f'F{n}'] = v['体重'][1]\n",
|
||||
" for xm in col.keys():\n",
|
||||
" if xm in v.keys():\n",
|
||||
" #print(v[xm][0])\n",
|
||||
" #print(v[xm][1])\n",
|
||||
" sheet[f'{col[xm]}{n}'] = v[xm][0] \n",
|
||||
" sheet[f'{col1[xm]}{n}'] = v[xm][1]\n",
|
||||
" n += 1 \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"wb.save(filename)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "43cc57b0-aebc-4315-b48f-9268e754bebb",
|
||||
|
||||
Reference in new issue
Block a user