1 |
3b598b4d
|
petrh
|
from Utilities.CSV import CSVDataLine, CSVutils
|
2 |
|
|
from Utilities import DateFormating
|
3 |
|
|
|
4 |
|
|
|
5 |
be637834
|
petrh
|
def process_file(filename):
|
6 |
3b598b4d
|
petrh
|
|
7 |
|
|
with open(filename, "r", encoding="utf-8") as file:
|
8 |
|
|
|
9 |
|
|
date_dict = dict()
|
10 |
|
|
|
11 |
|
|
for line in file:
|
12 |
|
|
|
13 |
|
|
array = line.split(";")
|
14 |
|
|
|
15 |
|
|
date = DateFormating.date_time_formater(array[4][1:-2])
|
16 |
|
|
name = array[1][1:-1]
|
17 |
|
|
occurence = array[0]
|
18 |
|
|
|
19 |
|
|
if date not in date_dict:
|
20 |
|
|
date_dict[date] = dict()
|
21 |
|
|
|
22 |
|
|
if name in date_dict[date]:
|
23 |
|
|
date_dict[date][name].occurence += int(occurence)
|
24 |
|
|
else:
|
25 |
|
|
date_dict[date][name] = CSVDataLine.CSVDataLine(name, date, int(occurence))
|
26 |
|
|
|
27 |
|
|
CSVutils.export_data_to_csv(filename, date_dict)
|