sertit.files.extract_file

extract_file(file_path: Union[str, cloudpathlib.cloudpath.CloudPath, pathlib.Path], output: Union[str, cloudpathlib.cloudpath.CloudPath, pathlib.Path], overwrite: bool = False) Union[list, cloudpathlib.cloudpath.CloudPath, pathlib.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.

>>> file_path = 'D:\path\to\zip.zip'
>>> output = 'D:\path\to\output'
>>> extract_file(file_path, output, overwrite=True)
D:\path\to\output\zip'
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, CloudPath, Path]