-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
40 lines (31 loc) · 1.3 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from pandas_ods_reader import read_ods
import collections
# the input is very basic, for further use it should take user input
# base_path = "eaqua_polybios_30sim_alltime_book1.ods"
# base_path = "eaqua_polybios_30sim_alltime_book3.ods"
# base_path = "eaqua_polybios_30sim_alltime.ods"
# base_path = "eaqua_cassiusdio_30sim_alltime.ods"
# base_path = "eaqua_diodorus_30sim_alltime.ods"
# base_path = "eaqua_plutarch_30sim_alltime.ods"
# base_path = "eaqua_livius_30sim_alltime.ods"
base_path = "eaqua_maurus_30sim_alltime.ods"
sheet_index = 1
df = read_ods(base_path)
authors = {}
print(f'Es wurden insgesamt {len(df)} Zeilen gefunden.')
def print_content(file):
for index, row in file.iterrows():
if not row[5] in authors:
authors[row[5]] = 1
else:
authors[row[5]] += 1
count_authors = len(authors)
print(f'Es gab insgesamt {count_authors} Autoren.')
sorted_list = sorted(authors.items(), key=lambda kv: kv[1], reverse=True)
sorted_list_dict = collections.OrderedDict(sorted_list)
for author in sorted_list_dict:
print(f'{author} wurde {sorted_list_dict[author]} mal gefunden.')
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_content(df)
# See PyCharm help at https://www.jetbrains.com/help/pycharm/