observations.maybe_download_and_extract

maybe_download_and_extract(
    directory,
    url,
    extract=True
)

Download file from url unless it already exists in specified directory. Extract the file if extract is True.

The file at url is downloaded to the directory directory with its original filename. For example, with url http://example.org/example.txt and directory ~/data, the downloaded file is located at ~/data/example.txt.

Args:

  • directory: str. Path to directory containing the file or where file will be downloaded.
  • url: str. URL to download from if file doesn't exist.
  • extract: bool, optional. If True, tries to extract the file if it has format 'gz', 'tar' (including 'tar.gz' and 'tar.bz'), or 'zip'.

Returns:

str. Path to downloaded or already existing file.