climateset / extract_climateset.py
climateset's picture
Upload extract_climateset.py
41cd61b verified
raw history blame
No virus
1.39 kB
from huggingface_hub import snapshot_download
import tarfile
from glob import glob
import os
# Path of the directory where the data will be downloaded in your local machine
local_directory = 'LOCAL_DIRECTORY'
# TODO : Token to access the private repository, delete when the repository will be public
access_token = "ACCESS_TOKEN"
repo_id = "climateset/causalpaca"
repo_type = "dataset"
# Uncomment the snapshot_download(...) function call to download the entire dataset from the HuggingFace Repository. This takes while.
print("Downloading the ClimateSet HuggingFace Repository...")
#snapshot_download(repo_id=repo_id, repo_type=repo_type, local_dir=local_directory, local_dir_use_symlinks=False, token=access_token)
print("Done.")
print("Extracting the compressed input data...")
input_files = glob(local_directory + "/inputs/*.tar.gz")
for input_file in input_files:
#tar = tarfile.open(input_file)
#tar.extractall(path=local_directory + "/inputs/")
#tar.close()
os.remove(input_file)
print("Done.")
print("Extracting the compressed output data...")
output_files = glob(local_directory + "/outputs/*.tar.gz")
for output_file in output_files:
#tar = tarfile.open(output_file)
#tar.extractall(path=local_directory + "/outputs/")
#tar.close()
os.remove(output_file)
print("Done.")
print("Done. Finished downloading and extracting the Climateset data! :)")