import csv


def load_pose(filename):
    """
    Loads initial and goal state information for a robot from a text file
    :param filename: path and name to the file with robot state information
    :return: dictionaries for the initial state and goal state
    """

    with open(filename, 'r', encoding='utf8') as fin:

        reader = csv.DictReader(fin, skipinitialspace=True, delimiter=',')

        raw_states = []
        for state in reader:

            temporary_state = {}
            for key, value in state.items():
                try:
                    temporary_state[key] = float(value)
                except ValueError:
                    temporary_state[key] = None

            raw_states.append(temporary_state)

    initial_state = raw_states[0]

    return initial_state