Projekt

Obecné

Profil

Stáhnout (631 Bajtů) Statistiky
| Větev: | Revize:
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 d6d75a03 petrh
        if len(date) != 13:
14
            raise ValueError("Invalid date format YYYY-dd-mm-hh expected!")    
15 2d129043 petrh
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