def validate_header(fields, required):
    """ Validate the header line in a source file. 
    
    Parameters
    ----------
    fields : list of str
        Each element is the name of a field from a header line
    required : set of str
        Each element is the name of a required field
        
    Returns
    -------
    dict
        Dictionary with field name as key and list index number as value
    """

    # Map field names to column numbers.
    names = {fields[index]: index for index in range(len(fields))}

    # Confirm that required field names are in the header line.
    for req in required:
        if req not in names:
            raise ValueError('Required field {0} is missing from header line'.format(req))

    return names