def _update_cases(self, filename):
    exceptions_raised = 0
    updates = {}
    counter = 0
    with open(filename, 'r') as _input:
        reader = csv.DictReader(_input)
        with open(('cases_without_mother_name_part_%s_updated.csv' % self.db_alias), 'w') as output:
            writer = csv.writer(output)
            writer.writerow(['Case ID', 'Mother Name'])
            for row in reader:
                updates[row['Case ID']] = row['Mother Name']
                counter += 1
                if ((counter > 0) and ((counter % 100) == 0)):
                    case_ids = self._reassured_case_ids_to_update(list(updates.keys()))
                    skip_ids = (updates.keys() - case_ids)
                    for case_id in skip_ids:
                        updates.pop(case_id)
                    for (case_id, mother_name) in updates.items():
                        writer.writerow([case_id, mother_name])
                    exceptions_raised = self._submit_update_form(updates, exceptions_raised)
                    if self.log_progress:
                        print(('cases updated: %s' % counter))
                    updates = {}
                    counter = 0
            for (case_id, mother_name) in updates.items():
                writer.writerow([case_id, mother_name])
            exceptions_raised = self._submit_update_form(updates, exceptions_raised)
def _update_cases(self, filename):
    exceptions_raised = 0
    updates = {}
    counter = 0
    with open(filename, 'r') as _input:
        reader = csv.DictReader(_input)
        with open(('cases_without_mother_name_part_%s_updated.csv' % self.db_alias), 'w') as output:
            writer = csv.writer(output)
            writer.writerow(['Case ID', 'Mother Name'])
            for row in reader:
                updates[row['Case ID']] = row['Mother Name']
                counter += 1
                if ((counter > 0) and ((counter % 100) == 0)):
                    case_ids = self._reassured_case_ids_to_update(list(updates.keys()))
                    skip_ids = (updates.keys() - case_ids)
                    for case_id in skip_ids:
                        updates.pop(case_id)
                    for (case_id, mother_name) in updates.items():
                        writer.writerow([case_id, mother_name])
                    exceptions_raised = self._submit_update_form(updates, exceptions_raised)
                    if self.log_progress:
                        print(('cases updated: %s' % counter))
                    updates = {}
                    counter = 0
            for (case_id, mother_name) in updates.items():
                writer.writerow([case_id, mother_name])
            exceptions_raised = self._submit_update_form(updates, exceptions_raised)