def _clean_values(val_dict, replace_internal_space=None, replace_null_val=
    None, subst_dict={}, filter_dict={}, predicate=None, predicate2=None):
    """Helper function for reformat_table. Clean the extracted values"""
    for key in val_dict.keys():
        val_dict[key] = val_dict[key].strip()
        if replace_null_val and not val_dict[key]:
            val_dict[key] = replace_null_val
        if replace_internal_space:
            val_dict[key] = val_dict[key].replace(' ', '_')
        if key in filter_dict and val_dict[key] in filter_dict[key]:
            return None
        if predicate and not predicate(val_dict):
            return None
        if predicate2 and not predicate2(val_dict):
            return None
        if key in subst_dict and val_dict[key] in subst_dict[key]:
            val_dict[key] = subst_dict[key][val_dict[key]]
    return val_dict
