Revize af7609b5
Přidáno uživatelem Tomáš Ballák před více než 3 roky(ů)
modules/crawler/DatasetProcessing/JIS_processor.py | ||
---|---|---|
1 | 1 |
from Utilities.CSV import csv_data_line |
2 | 2 |
from Utilities import date_formating |
3 | 3 |
|
4 |
from shared_types import DateDict |
|
4 | 5 |
|
5 |
def process_file(filename): |
|
6 |
|
|
7 |
def process_file(filename: str) -> DateDict: |
|
6 | 8 |
""" |
7 | 9 |
Method that take path to crawled file and outputs date dictionary: |
8 | 10 |
Date dictionary is a dictionary where keys are dates in format YYYY-mm-dd-hh (2018-04-08-15) |
... | ... | |
16 | 18 |
None if not implemented |
17 | 19 |
date_dict when implemented |
18 | 20 |
""" |
19 |
date_dict = dict()
|
|
21 |
date_dict = {}
|
|
20 | 22 |
|
21 | 23 |
with open(filename, "r", encoding="utf-8") as file: |
22 | 24 |
|
... | ... | |
29 | 31 |
occurrence = array[2][:-1] |
30 | 32 |
|
31 | 33 |
if date not in date_dict: |
32 |
date_dict[date] = dict()
|
|
34 |
date_dict[date] = {}
|
|
33 | 35 |
|
34 | 36 |
if name in date_dict[date]: |
35 | 37 |
date_dict[date][name].occurrence += int(occurrence) |
36 | 38 |
else: |
37 |
date_dict[date][name] = csv_data_line.CSVDataLine(name, date, occurrence) |
|
39 |
date_dict[date][name] = csv_data_line.CSVDataLine( |
|
40 |
name, date, occurrence) |
|
38 | 41 |
|
39 | 42 |
return date_dict |
40 |
|
Také k dispozici: Unified diff
Re #8193 - refactoring crawler