extract_archive()

audeer.extract_archive(archive, destination, *, keep_archive=True, verbose=False)[source]

Extract ZIP or TAR file.

Parameters
  • archive (str) – path to ZIP or TAR file

  • destination (str) – folder where the files will be extracted. If the folder does not exists, it will be created

  • keep_archive (bool) – if False delete archive file after extraction

  • verbose (bool) – if True a progress bar is shown

Return type

list[str]

Returns

paths of extracted files relative to destination in order they were added to the archive

Raises

Examples

>>> folder = audeer.path(".")
>>> file = audeer.touch(folder, "a.txt")
>>> archive = audeer.path("archive.zip")
>>> audeer.create_archive(folder, None, archive)
>>> audeer.extract_archive(archive, ".")
['a.txt']
>>> audeer.extract_archive(archive, "sub")
['a.txt']