code: def asindices(hdr, spec):
      
  
      flds = list(map(text_type, hdr))
      indices = list()
      if not isinstance(spec, (list, tuple)):
          spec = (spec,)
      for s in spec:
          # spec could be a field index (takes priority)
          if isinstance(s, int) and s < len(hdr):
              indices.append(s)  # index fields from 0
          # spec could be a field
          elif s in flds:
              indices.append(flds.index(s))
          else:
              raise FieldSelectionError(s)
      return indices
docs: Convert the given field `spec` into a list of field indices.