code: def open_file(loc):
      
      loc = ensure_path(loc)
      if tarfile.is_tarfile(str(loc)):
          return tarfile.open(str(loc), "r:gz")
      elif loc.parts[-1].endswith("gz"):
          return (line.decode("utf8") for line in gzip.open(str(loc), "r"))
      elif loc.parts[-1].endswith("zip"):
          zip_file = zipfile.ZipFile(str(loc))
          names = zip_file.namelist()
          file_ = zip_file.open(names[0])
          return (line.decode("utf8") for line in file_)
      else:
          return loc.open("r", encoding="utf8")
docs: Handle .gz, .tar.gz or unzipped files