<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def read_criteria_file(self, criteria_file):
        '''
        read criteria file.
        initialize self.acceptance_criteria
        try to guess if averaging by sample or by site.
        '''
        if self.data_model == 3:
            self.acceptance_criteria = pmag.initialize_acceptance_criteria(
                data_model=self.data_model)
            self.add_thellier_gui_criteria()
            fnames = {'criteria': criteria_file}
            contribution = cb.Contribution(
                self.WD, custom_filenames=fnames, read_tables=['criteria'])
            if 'criteria' in contribution.tables:
                crit_container = contribution.tables['criteria']
                crit_data = crit_container.df
                crit_data['definition'] = 'acceptance criteria for study'
                # convert to list of dictionaries
                self.crit_data = crit_data.to_dict('records')
                for crit in self.crit_data:  # step through and rename every f-ing one
                    # magic2[magic3.index(crit['table_column'])] # find data
                    # model 2.5 name
                    m2_name = map_magic.convert_intensity_criteria(
                        'magic2', crit['table_column'])
                    if not m2_name:
                        pass
                    elif m2_name not in self.acceptance_criteria:
                        print('-W- Your criteria file contains {}, which is not currently supported in Thellier GUI.'.format(m2_name))
                        print('    This record will be skipped:\n    {}'.format(crit))
                    else:
                        if m2_name != crit['table_column'] and 'scat' not in m2_name != "":
                            self.acceptance_criteria[m2_name]['value'] = float(
                                crit['criterion_value'])
                            self.acceptance_criteria[m2_name]['pmag_criteria_code'] = crit['criterion']
                        if m2_name != crit['table_column'] and 'scat' in m2_name != "":
                            if crit['criterion_value'] == 'True':
                                self.acceptance_criteria[m2_name]['value'] = 1
                            else:
                                self.acceptance_criteria[m2_name]['value'] = 0
            else:
                print("-E- Can't read criteria file")

        else:  # Do it the data model 2.5 way:
            self.crit_data = {}
            try:
                self.acceptance_criteria = pmag.read_criteria_from_file(
                    criteria_file, self.acceptance_criteria)
            except:
                print("-E- Can't read pmag criteria file")
        # guesss if average by site or sample:
        by_sample = True
        flag = False
        for crit in ['sample_int_n', 'sample_int_sigma_perc', 'sample_int_sigma']:
            if self.acceptance_criteria[crit]['value'] == -999:
                flag = True
        if flag:
            for crit in ['site_int_n', 'site_int_sigma_perc', 'site_int_sigma']:
                if self.acceptance_criteria[crit]['value'] != -999:
                    by_sample = False
        if not by_sample:
            self.acceptance_criteria['average_by_sample_or_site']['value'] = 'site'