def filterlist(initlist, list_of_strings_to_add, list_of_fields):
    """
    add elem of list_of_strings_to_add that are in list_of_fields in initlist

    and raise an error if elem is not in list_of_fields
    """
    for elem in list_of_strings_to_add:
        if elem in list_of_fields:
            initlist += [elem]
        else:
            raise ValueError(
                'tableallspots.fields : %s does not contain this requested field: %s '
                 % (list_of_fields, elem))
    return initlist
