def _get_dict_from_file( f ):
    """Returns a dictionary mapping the first csv entry to a set of the rest

    I.e. 'key,value1,value2,value3' is converted to

    result[ key ] = set( value1, value2, value3 )

    f can be a string or a filehandle
    """

    # if a string was passed in, convert it to a file handle
    if str == type( f ):
        f = open( f, 'r' )

    result = { }

    for line in f:

        # get the csv fields
        fields = line.strip( '\r\n' ).split( ',' )
        if len( fields ) < 1:
            continue

        # the first is the key
        key = fields[ 0 ]
        result[ key ] = set( fields[ 1: ] )

    return result