garmentiq.utils.unzip

Extracting a dataset archive.

 1"""Extracting a dataset archive."""
 2import zipfile
 3from tqdm.auto import tqdm
 4
 5
 6def unzip(zip_path, extract_to="."):
 7    """
 8    Extracts the contents of a ZIP file with a progress bar.
 9
10    This function unzips the contents of the specified ZIP file to the given directory.
11    A progress bar is displayed during the extraction using `tqdm`.
12
13    Args:
14        zip_path (str): Path to the ZIP file to be extracted.
15        extract_to (str): Destination directory where the contents will be extracted. Defaults to the current directory.
16
17    Returns:
18        None
19    """
20    with zipfile.ZipFile(zip_path, "r") as zip_ref:
21        members = zip_ref.infolist()
22        for member in tqdm(members, desc="Extracting"):
23            zip_ref.extract(member, extract_to)
def unzip(zip_path, extract_to='.'):
 7def unzip(zip_path, extract_to="."):
 8    """
 9    Extracts the contents of a ZIP file with a progress bar.
10
11    This function unzips the contents of the specified ZIP file to the given directory.
12    A progress bar is displayed during the extraction using `tqdm`.
13
14    Args:
15        zip_path (str): Path to the ZIP file to be extracted.
16        extract_to (str): Destination directory where the contents will be extracted. Defaults to the current directory.
17
18    Returns:
19        None
20    """
21    with zipfile.ZipFile(zip_path, "r") as zip_ref:
22        members = zip_ref.infolist()
23        for member in tqdm(members, desc="Extracting"):
24            zip_ref.extract(member, extract_to)

Extracts the contents of a ZIP file with a progress bar.

This function unzips the contents of the specified ZIP file to the given directory. A progress bar is displayed during the extraction using tqdm.

Arguments:
  • zip_path (str): Path to the ZIP file to be extracted.
  • extract_to (str): Destination directory where the contents will be extracted. Defaults to the current directory.
Returns:

None