Home > other >  Can't write, for help
Can't write, for help

Time:09-22

GBK and utf8 folder file respectively suitable for Windows and MAC OS (Linux),

1) id. TXT inside put the name and student id, no sorting,

2) finalscore inside put the student's information to solve the problem, which is the third or fourth column number, to solve the problem.

3) fraction computational method: 1, 2 50 questions to 60, since each do one plus four points,

4) requirements generated id. TXT in all the grades of the students, according to the student id sorting result output to the result file. TXT, if in finalscore find student records, to solve the problem of the student number and the results are 0,

5) result. TXT format, such as:

Student id name writing score

1700943357 Wang Xiaobin 0 0

1700943359 li xunran 0 0

1700943383 10) crier 2 60

1700943405 Chen Jielun 0 0

1700943465 BaoQiao ran 5 72

1700943469 WuJunJie 3 64

More than 1700943472 Zhong Dian 0 0

1700943481 kimico Chen "0 0

1700943523 Zhao Sheng Cong 7 80

6) will be the result. The information in the TXT import excel spreadsheets (text import, copy and paste),

7) id. TXT there is no student, don't tube,

Note:

Source file and target file separator, no Spaces, tabs \ t (Tab), look for the finalscore. TXT, inside there is connected to two Tab, such as between student number and the number to solve the problem is below 2 Tab:

4 1700943836 9

Maybe you need to pay attention to this point, may not need,

8) rusult. TXT and the resulting excel file upload compressed, with their student id as a compressed file filename,

CodePudding user response:

Read ID. TXT and finalscore judgment and score draw, write the result, also can write SCV, import excel again

CodePudding user response:

The from openpyxl import Workbook
The from openpyxl. Worksheet. Table import table, TableStyleInfo
Total_dict=[]
F1=open (' id. TXT ', 'r', encoding='utf-8 - sig)
For the line in f1. Readlines () :
Tempdict={' student id ': ""," name ":" ",' number ': 0,' scores' : 0,}
Lines=line. The split (" \ t ")
# print (lines [0], lines [1])
Lines [0]=lines [0]. The strip ()
Lines [1]=lines [1]. The strip ()
Tempdict [' student id ']=lines [0]
Tempdict [' name ']=lines [1]
Total_dict. Append (tempdict)
F1. The close ()
F2=open (' finalscore. TXT ', 'r', encoding="utf-8")
For the line in f2. Readlines () :
Lines=line. The split (" \ t ")
Quesnum=int (lines [2])
Stid=lines [1]
Score=(lambda quesnum: 0 if quesnum==0 the else if 50 quesnum else 60 if quesnum====1 2 else 60 + (quesnum - 2) * 4)
Getsco=score (quesnum)
For dict1 total_dict in:
If stid==dict1 [' student id '] :
Dict1 [' title number]=quesnum
Dict1 [' scores']=getsco
F2. The close ()
F3=open (' result. TXT ', 'w')
F3. Write (' student id '+' name '" \ t "+ +" \ t "+' title number +" \ t "+ 'scores' +" \ n ")
For dict1 total_dict in:
F3. Write (dict1 [' student id '] + "\ t" + dict1 [' name '] + "\ t" + STR (dict1 [' writing ']) + "\ t" + STR (dict1 [' scores']) + "\ n")
F3. Close ()



Wb=Workbook ()
Ws=wb. Active
Ws. Append ([' student id ', 'name', 'writing', 'scores'])
For dict1 total_dict in:
Ws. Append (a list (dict1 values ()))
TAB=Table (displayName="Table1", ref="A1: D" + STR (len (total_dict) + 1)) # name manager
1-21 # 'TableStyleLight11' and this style "TableStyleMedium9" 1-28 TableStyleDark1 1-11
# showFirstColumn=True,
# showLastColumn=True, showRowStripes=True, showColumnStripes=True)
# if the first line style and colour is the same as the first line, the second column is...
# are interlaced in color, whether every column color change
Style=TableStyleInfo (name='TableStyleDark11, showFirstColumn=True,
ShowLastColumn=True, showRowStripes=False, showColumnStripes=True)
TAB. TableStyleInfo=style
Ws. Add_table (TAB)
Wb. Save (' s2. XLSX)

CodePudding user response:

Id. TXT

1700943357 Wang Xiaobin
 
1700943359 li xunran
1700943383 10) crier
1700943405 Chen Jielun
1700943465 BaoQiao rush
1700943469 WuJunJie
More than 1700943472 Zhong Dian

1700943481 kimico Chen"1700943523 Zhao Sheng Cong


Finalscore. TXT

 0, 1700943357 
20, 1700943359
0, 1700943383
20, 1700943405
0, 1700943465
0 1700943469 3
0, 1700943472
0, 1700943481
0, 1700943523


Result. TXT
 student id name writing score 
1700943357 Wang Xiaobin 2 60
1700943359 li xunran 0 0
1700943383 10) crier 2 60
1700943405 Chen Jielun 0 0
1700943465 BaoQiao ran 5 72
1700943469 WuJunJie 3 64
More than 1700943472 Zhong Dian 0 0
1700943481 kimico Chen "0 0
1700943523 Zhao Sheng Cong 7 80
  • Related