Esempio n. 1
0
def check_files_are_up_to_date():
    # linker files have been changed. call make_linked_dict to go from scratch. main() loads the file
    """Creates a pkl file that marks if each of the files are up to date and updates them if not
    If the modification date on either pp-complete or normalised_bp_data, re do everything"""

    check_file = f'{resources_file}/check.pkl'

    # Init the file
    if os.path.exists(check_file) is False:
        pp_mod = os.path.getmtime(f'{resources_file}/pp-complete.csv')
        bp_mod = os.path.getmtime(f'{resources_file}/normalised_bp_data.csv')
        with open(check_file, 'wb') as f:
            pickle.dump({'pp': pp_mod, 'bp': bp_mod}, f)

    # Get file for last mod for files
    else:
        with open(check_file, 'rb') as f:
            d = pickle.load(f)
            pp_mod = d['pp']
            bp_mod = d['bp']

    if pp_mod != os.path.getmtime(
            f'{resources_file}/pp-complete.csv') or bp_mod != os.path.getmtime(
                f'{resources_file}/normalised_bp_data.csv'):
        print('UPDATING ALL FILES')
        # re do everything
        tools.read_pp(short_cut=False)  # compresses_bp_data.h5
        pp_metadata.load_meta_data(from_scratch=True)  # metadata.csv
        linker.ExactLinker().main()  # exact_link.pkl
        linker.ExtractBPAddressesData().main()  # exact_bp_address_data.pkl
Esempio n. 2
0
 def __init__(self, data_type='exact'):
     if data_type == 'exact':
         self.linker_dict = ExactLinker.main()
     elif data_type == 'postcode':
         self.linker_dict = PostcodeLinker.main()
     else:
         raise TypeError('Needs data_type arg to be exact or postcode')
     self.pp = tools.read_pp()
     self.bp = tools.read_bp().set_index('address')
     self.metadata = metadata.load_meta_data()
     self.before_after_dict = {
     }  # See get_before_after_from_linker() for where it is used.
 def __init__(self, df, addresses_column_name):
     self.df = df
     self.address_column = addresses_column_name
     if addresses_column_name not in df.columns:
         raise TypeError('Incorrect Column Name')
     self.pp = tools.read_pp()
Esempio n. 4
0
 def __init__(self):
     self.pp = tools.read_pp()
     self.bp = tools.read_bp().set_index('address')
     self.metadata = pp_metadata.load_meta_data()
     self.data_file_path = f'{resources_file}/repeated_measures_data.pkl'
Esempio n. 5
0
 def __init__(self):
     self.pp = tools.read_pp()
     self.bp = tools.read_bp()
 def __init__(self):
     print('Calculating Metadata')
     self.pp = tools.read_pp()
 def __init__(self, input_addresses):
     self.input_address = input_addresses
     self.pp = tools.read_pp()