-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathload_and_save_data.py
54 lines (27 loc) · 1.07 KB
/
load_and_save_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 20/02/19
@author: Maurizio Ferrari Dacrema
"""
from Base.DataIO import DataIO
def save_data_dict_zip(URM_DICT, ICM_DICT, splitted_data_path, file_name_prefix):
dataIO = DataIO(folder_path = splitted_data_path)
URM_DICT["__ICM_available"] = len(ICM_DICT)>0
dataIO.save_data(data_dict_to_save = URM_DICT, file_name=file_name_prefix + "URM_dict")
del URM_DICT["__ICM_available"]
if len(ICM_DICT)>0:
dataIO.save_data(data_dict_to_save = ICM_DICT, file_name=file_name_prefix + "ICM_dict")
def load_data_dict_zip(splitted_data_path, file_name_prefix):
URM_DICT = {}
ICM_DICT = {}
dataIO = DataIO(folder_path = splitted_data_path)
URM_DICT = dataIO.load_data(file_name=file_name_prefix + "URM_dict")
if URM_DICT["__ICM_available"]:
ICM_DICT = dataIO.load_data(file_name=file_name_prefix + "ICM_dict")
del URM_DICT["__ICM_available"]
loaded_data_dict = {
"URM_DICT": URM_DICT,
"ICM_DICT": ICM_DICT,
}
return loaded_data_dict