Projekt

Obecné

Profil

Stáhnout (1.23 KB) Statistiky
| Větev: | Revize:
1
from Utilities.CSV import CSVDataLine, CSVutils
2
from Utilities import DateFormating
3

    
4

    
5
def process_file(filename):
6
    """
7
    Method that take path to crawled file and outputs date dictionary using method:
8
    CSVutils.export_data_to_csv(filename, date_dict)
9
    Date dictionary is a dictionary where keys are dates in format ddmmYYYYhh (0804201815)
10
    and value is dictionary where keys devices (specified in configuration file)
11
    and value is CSVDataLine.CSVDataLine with device,date and occurrence
12

    
13
    Args:
14
        filename: name of processed file
15

    
16
    Returns:
17
        False if not implemented
18
        True when implemented
19
    """
20
    with open(filename, "r") as file:
21

    
22
        date_dict = dict()
23

    
24
        for line in file:
25

    
26
            array = line.split(";")
27

    
28
            date = DateFormating.date_time_formatter(array[0][1:-1])
29
            name = array[1][1:-1]
30

    
31
            if date not in date_dict:
32
                date_dict[date] = dict()
33

    
34
            if name in date_dict[date]:
35
                date_dict[date][name].occurence += 1
36
            else:
37
                date_dict[date][name] = CSVDataLine.CSVDataLine(name, date, 1)
38

    
39
    CSVutils.export_data_to_csv(filename, date_dict)
40
    return True
41

    
(2-2/3)