aswi2020sebela-gitlab/modules/crawler/Utilities/CSV/csv_data_line.py @ af7609b5
1 | c8f3051b | petrh | class CSVDataLine: |
---|---|---|---|
2 | 04a2b5a4 | petrh | """
|
3 | Class that specifies the look of data line in processed csv file
|
||
4 | prepared for database
|
||
5 | """
|
||
6 | af7609b5 | Tomáš Ballák | def __init__(self, name: str, date: str, occurrence: int) -> None: |
7 | 2d129043 | petrh | try: |
8 | test_val = int(occurrence) |
||
9 | except ValueError: |
||
10 | print("Occurence should be and integer value!") |
||
11 | |||
12 | d6d75a03 | petrh | if len(date) != 13: |
13 | af7609b5 | Tomáš Ballák | raise ValueError("Invalid date format YYYY-dd-mm-hh expected!") |
14 | 2d129043 | petrh | |
15 | c8f3051b | petrh | self.name = name |
16 | self.date = date |
||
17 | 2d129043 | petrh | self.occurrence = test_val |
18 | c8f3051b | petrh | |
19 | af7609b5 | Tomáš Ballák | def to_csv(self) -> str: |
20 | 04a2b5a4 | petrh | return self.name + ";" + str(self.occurrence) + ";" + self.date |