Sort Code section added

In the previous article, we have successfully prepared a py file, to achieve an online document processing automated data processing excell score, and package it into a exe executable file, but the file was py, we did not do the process results in accordance with good results sorted out, and now we have added code for this part of the complete program are as follows:

openpyxl Import 
Import os
Import SYS
from openpyxl Import load_workbook

Data_Path = the INPUT ( "Please enter a file path >> =====" )
Sheet = load_workbook (Data_Path )
sheet1 = sheet.get_sheet_by_name ( 'Sheet1' ) ### this is to read data table
Sheet2 = sheet.get_sheet_by_name ( 'Sheet2' ) ### write the result data set
### to read data from the first table sheet1
DATA_LIST = []
for I in Range (2, 42 is ) :
List1 = [] for J in Range (. 1,. 4 ) : IF J

== 1:
list1.append(sheet1.cell(i, j).value)
else:
try:
list1.append(int(sheet1.cell(i, j).value))
except PermissionError:
continue
data_list.append(list1)

data_list1 = []
for i in data_list:
sum = i[1] + i[2] * 2 #####最终的总分计算公式,可以更改
i.append(sum)
data_list1.append(i)

print(len(data_list1))
# A1, a2, a3, a4 , a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25 , a26, a27, a28, a29 , a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40 = data_list1


next bubble sort according to the idea of, one by one exchange location ####, dynamic sorting,
for I in Range (0, len (data_list1 )) : for J in Range (I, len (data_list1 )) : IF data_list1 [I ] [. 3 ] <data_list1 [J ] [. 3 ]: data_list1 [I ] , data_list1 [J ] = data_list1 [J ], data_list1 [I ] ### writes the result in sheet2 for I in Range (0, len







(data_list1)):
for j in range(0, 4):
sheet2.cell(i + 2, j + 1).value = data_list1[i][j]

sheet.save(data_path)

Guess you like

Origin www.cnblogs.com/1832921tongjieducn/p/11794814.html