Revize af7609b5
Přidáno uživatelem Tomáš Ballák před více než 3 roky(ů)
modules/crawler/Utilities/CSV/csv_utils.py | ||
---|---|---|
1 | 1 |
import inspect |
2 |
from shared_types import StringSetType |
|
2 | 3 |
from Utilities.CSV import csv_data_line |
3 | 4 |
|
4 | 5 |
# Path to processed data |
5 | 6 |
PROCESSED_DATA_PATH = "ProcessedData/" |
6 | 7 |
|
7 | 8 |
|
8 |
def get_unique_names_from_file(filename, column_number): |
|
9 |
def get_unique_names_from_file(filename: str, |
|
10 |
column_number: int) -> StringSetType: |
|
9 | 11 |
""" |
10 | 12 |
Extract set of unique names from file |
11 | 13 |
Args: |
... | ... | |
29 | 31 |
return name_set |
30 | 32 |
|
31 | 33 |
|
32 |
def export_data_to_csv(filename, data_dict):
|
|
34 |
def export_data_to_csv(filename: str, data_dict) -> None:
|
|
33 | 35 |
""" |
34 | 36 |
Takes data_dict and export it into a csv file |
35 | 37 |
Args: |
... | ... | |
40 | 42 |
|
41 | 43 |
for date in data_dict: |
42 | 44 |
if len(date) != 13: |
43 |
raise ValueError("Invalid date format for key value --> YYYY-mm-dd-hh expected!") |
|
45 |
raise ValueError( |
|
46 |
"Invalid date format for key value --> YYYY-mm-dd-hh expected!" |
|
47 |
) |
|
44 | 48 |
for data in data_dict[date]: |
45 | 49 |
csv_line = data_dict[date][data] |
46 |
if not isinstance(csv_line,csv_data_line.CSVDataLine): |
|
47 |
raise ValueError("data_dict is expected to have CSVDataLine as values") |
|
50 |
if not isinstance(csv_line, csv_data_line.CSVDataLine): |
|
51 |
raise ValueError( |
|
52 |
"data_dict is expected to have CSVDataLine as values") |
|
48 | 53 |
file.write(csv_line.to_csv() + '\n') |
Také k dispozici: Unified diff
Re #8193 - refactoring crawler