loading

download_file(url: str, output_file: str | PathLike, show_progress=False, overwrite_existing=False, headers: Dict[str, str] | None = None)[source]

Download a file via HTTP[S] to a specified directory

Parameters:
  • url – URL of the file to be downloaded

  • output_file – Destination path for the downloaded file

  • show_progress – show a progress bar using tqdm

  • overwrite_existing – whether to overwrite existing files

  • headers – Optional headers to add to request, e.g. {“Authorization”: “Bearer <access_token>” }

open_file_in_tar(path: str | PathLike, file_regex: str | Pattern = '.*') BufferedReader[source]

Opens an archived file in memory without extracting it on disc. Use as context manager: >>> with open_file_in_tar(…) as fh: pass

Parameters:
  • path – Local file path to the tar archive.

  • file_regex – A regular expression which will be matched against the files in the archive. The matching file will be returned.

Raises:

ValueError – when the file_regex matches multiple or no file in the archive.