Projekt

Obecné

Profil

Stáhnout (818 Bajtů) Statistiky
| Větev: | Revize:
1 04a2b5a4 petrh
# Path to processed data
2 c8f3051b petrh
PROCESSED_DATA_PATH = "ProcessedData/"
3
4 04a2b5a4 petrh
5 c8f3051b petrh
def get_unique_names_from_file(filename, column_number):
6 04a2b5a4 petrh
    """
7
8
    Args:
9
        filename:
10
        column_number:
11
12
    Returns:
13
14
    """
15 c8f3051b petrh
    f = open(filename, "r")
16
17
    # create set of unique names
18
    name_set = set()
19
20
    # go through every line of line
21
    for x in f:
22
        # split by csv splitter ;
23
        array = x.split(";")
24
        # add string from chosen column to set
25
        name_set.add(array[column_number])
26
27
    f.close()
28
29
    return name_set
30
31
32
def export_data_to_csv(filename, data_dict):
33
    with open(PROCESSED_DATA_PATH + filename[12:], "w+") as file:
34
35
        for date in data_dict:
36
            for data in data_dict[date]:
37
                file.write(data_dict[date][data].to_csv() + '\n')