Revize 9387fbe6
Přidáno uživatelem Petr Hlaváč před téměř 5 roky(ů)
python-module/DatasetProcessing/JISProcessor.py | ||
---|---|---|
1 |
from Utilities.CSV import CSVDataLine, CSVutils |
|
2 |
from Utilities import DateFormating |
|
3 |
|
|
4 |
|
|
1 | 5 |
def process_file(filename): |
2 |
print("You must implements process_file method first!") |
|
6 |
|
|
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[1][1:-1]) |
|
16 |
name = array[0][1:-1] |
|
17 |
occurence = array[2][:-1] |
|
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) |
Také k dispozici: Unified diff
Re #7932 Implementovan dataProcessor pro JIS