code: def str_to_num(i, exact_match=True):
      
      # TODO: Cleanup -- this is really ugly
      if not isinstance(i, str):
          return i
      try:
          if not exact_match:
              return int(i)
          elif str(int(i)) == i:
              return int(i)
          elif str(float(i)) == i:
              return float(i)
          else:
              pass
      except ValueError:
          pass
      return i
docs: Attempts to convert a str to either an int or float