def select_title(apps, schema_editor):
    """
    Select (hopefully) appropriate titles for existing customer data.
    """
    MALE = 'M'
    FEMALE = 'F'
    MR = 'MR'
    MRS = 'MRS'
    MISS = 'MISS'
    MS = 'MS'
    DR = 'DR'
    PROF = 'PROF'
    REV = 'REV'
    TITLE_CHOICES = {MR: 'Mr', MRS: 'Mrs', MISS: 'Miss', MS: 'Ms', DR: 'Dr',
        PROF: 'Prof', REV: 'Rev'}
    Customer = apps.get_model('diary', 'Customer')
    for customer in Customer.objects.all():
        if customer.first_name in TITLE_CHOICES:
            customer.title = TITLE_CHOICES.keys()[TITLE_CHOICES.values().
                index(customer.first_name)]
            customer.first_name = ''
        elif customer.gender:
            customer.title = MR if customer.gender == MALE else MRS
        customer.save()
