def convert(value, row):
    ''' rapstatex -> dsource
    
    Simple crosswalk conversion to convert rapstatex into dsource. If rapstate is not present
    in the crosswalk add the value to a report showing frequency of all missing values.'''
    
    #If rapstate is blank set dsource to 9
    if not row['rapstatex']:
        return 9
    
    #Try to find rapstatex in the crosswalk and set dsource to associated value
    try:
        return int(crosswalk['default'].convert(row['rapstatex'].lower()))
    except ConvertError:
        #write to the log file values of rapstatex not present in the crosswalk and set dsource = 9
        log.write('dsource', [row['id'], row['rapstatex'], row['rapstatex'], "state not recognized"])
        return 9
