def get_sample_ids(map_data, map_header, states):
 name_to_col = dict([(s, map_header.index(s)) for s in states])
 good_ids = []
 for row in map_data:
  include = True
  for (s, vals) in states.items():
   curr_state = row[name_to_col[s]]
   include = (include and ((curr_state in vals) or ('*' in vals)) and (not (('!' + curr_state) in vals)))
  if include:
   good_ids.append(row[0])
 return good_ids

def get_sample_ids ( map_data , map_header , states ) : name_to_col = dict ( [ ( s , map_header . index ( s ) ) for s in states ] ) good_ids = [ ] for row in map_data : include = True for ( s , vals ) in states . items ( ) : curr_state = row [ name_to_col [ s ] ] include = ( include and ( ( curr_state in vals ) or ( '*' in vals ) ) and ( not ( ( '!' + curr_state ) in vals ) ) ) if include : good_ids . append ( row [ 0 ] ) return good_ids
takes col states in {col:[vals]} format .