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 |
2d129043
|
petrh
|
|
7 |
04a2b5a4
|
petrh
|
def __init__(self, name, date, occurrence):
|
8 |
2d129043
|
petrh
|
try:
|
9 |
|
|
test_val = int(occurrence)
|
10 |
|
|
except ValueError:
|
11 |
|
|
print("Occurence should be and integer value!")
|
12 |
|
|
|
13 |
|
|
if len(date) != 10:
|
14 |
|
|
raise ValueError("Invalid date format ddmmYYYYhh expected!")
|
15 |
|
|
|
16 |
c8f3051b
|
petrh
|
self.name = name
|
17 |
|
|
self.date = date
|
18 |
2d129043
|
petrh
|
self.occurrence = test_val
|
19 |
c8f3051b
|
petrh
|
|
20 |
|
|
def to_csv(self):
|
21 |
04a2b5a4
|
petrh
|
return self.name + ";" + str(self.occurrence) + ";" + self.date
|
22 |
c8f3051b
|
petrh
|
|