def convert_empty_value_to_none(event, key_name):
    """ Changes an empty string of "" or " ", and empty list of [] or an empty dictionary of {} to None so it will be NULL in the database

    :param event: A dictionary
    :param key_name: The key for which to check for empty strings
    :return: An altered dictionary

    Examples:

    .. code-block:: python

        # Example #1
        event = {'a_field': ' '}
        event = convert_empty_value_to_none(event, key_name='a_field')
        event = {'a_field': None}

        # Example #2
        event = {'a_field': '{}'}
        event = convert_empty_value_to_none(event, key_name='a_field')
        event = {'a_field': None}

        # Example #3
        event = {'a_field': {}}
        event = convert_empty_value_to_none(event, key_name='a_field')
        event = {'a_field': None}

    """

    if key_name in event:
        if type(event[key_name]) == str and (event[key_name] == '' or event[key_name].strip() == '' or event[key_name] == '{}' or event[key_name] == '[]'):
            event[key_name] = None

        # Converts an empty list or dictionary to None
        if not event[key_name]:
            event[key_name] = None

    return event