import re


def convert_string_to_snake_case(name):
    """ Converts a string to Snake Case

    :param name: A string
    :return: A string in snake case

    Example use case:
    - Events from might have custom properties in camelCase like userId, and userEmail
    - Use this to rename keys to user_id and user_email for better ease of reading in the database

    Examples:

    .. code-block:: python

        # Example #1
        input_string = 'MakeThisSnakeCase'
        output_string = convert_string_to_snake_case(input_string)
        output_string = 'make_this_snake_case'

        # Example #2
        input_string = 'Make This Snake Case'
        output_string = convert_string_to_snake_case(input_string)
        output_string = 'make_this_snake_case'

        # Example #3
        input_string = 'keep_this_snake_case'
        output_string = convert_string_to_snake_case(input_string)
        output_string = 'keep_this_snake_case'

    """

    s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
    sl = re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
    return sl.replace(' ', '')