extract_file

Contents

extract_file#

extract_file(file_path: str | CloudPath | Path, output: str | CloudPath | Path, overwrite: bool = False) list | CloudPath | Path[source]#

Extract an archived file (zip or others). Overwrites if specified. For zipfiles, in case of multiple folders archived, pay attention that what is returned is the first folder.

Parameters:
  • file_path (str) – Archive file path

  • output (str) – Output where to put the extracted file

  • overwrite (bool) – Overwrite found extracted files

Returns:

Extracted file paths (as str if only one)

Return type:

Union[list, AnyPathType]

Example

>>> file_path = 'D:/path/to/zip.zip'
>>> output = 'D:/path/to/output'
>>> extract_file(file_path, output, overwrite=True)
D:/path/to/output.zip'