1 resp
= input('Type 1 to view desc, 2 to view asc: ')
3 file = open('stats.txt', 'r')
4 file_text_arr
= file.read().split('\n')
5 file_text_arr_proc
= []
6 text_input
= "Board -- Total Bans / Posts per day DESC\n\n"
7 for text
in file_text_arr
:
8 text
= text
.strip().replace('\t', '').replace('\r', '').replace('\n', '')
9 file_text_arr_proc
.append(text
.split('--'))
10 for indexA
, text_groupA
in enumerate(file_text_arr_proc
):
11 for indexB
, text_groupB
in enumerate(file_text_arr_proc
):
12 if float(text_groupB
[1]) < float(text_groupA
[1]) and indexB
< indexA
:
13 current_group
= file_text_arr_proc
[indexA
]
14 file_text_arr_proc
[indexA
] = file_text_arr_proc
[indexB
]
15 file_text_arr_proc
[indexB
] = current_group
16 for text_group
in file_text_arr_proc
:
17 text_input
= text_input
+ text_group
[0] + '\t--\t' + text_group
[1] + '\n'
18 asc_file
= open('stats-desc-bans.txt', 'w')
19 asc_file
.write(text_input
)
22 file = open('stats.txt', 'r')
23 file_text_arr
= file.read().split('\n')
24 file_text_arr_proc
= []
25 text_input
= "Board -- Total Bans / Posts per day ASC\n\n"
26 for text
in file_text_arr
:
27 text
= text
.strip().replace('\t', '').replace('\r', '').replace('\n', '')
28 file_text_arr_proc
.append(text
.split('--'))
29 for indexA
, text_groupA
in enumerate(file_text_arr_proc
):
30 for indexB
, text_groupB
in enumerate(file_text_arr_proc
):
31 if float(text_groupB
[1]) > float(text_groupA
[1]) and indexB
< indexA
:
32 current_group
= file_text_arr_proc
[indexA
]
33 file_text_arr_proc
[indexA
] = file_text_arr_proc
[indexB
]
34 file_text_arr_proc
[indexB
] = current_group
35 for text_group
in file_text_arr_proc
:
36 text_input
= text_input
+ text_group
[0] + '\t--\t' + text_group
[1] + '\n'
37 asc_file
= open('stats-asc-bans.txt', 'w')
38 asc_file
.write(text_input
)