def get_field(field, row, field_map, default_value=None):
  """Access fields in a row according to the specified field map.

  Args:
    field: field to extract.
    row: row to extract field from.
    field_map: field map.
    default_value: value to be returned in case the field is not mapped.
  Returns:
    specified field value if the field is mapped, the default value otherwise.
  """

  field_info = field_map.get(field)

  if not field_info:
    return default_value
  else:
    return row[field_info['idx']]