climateset commited on
Commit
41cd61b
1 Parent(s): b0b02cc

Upload extract_climateset.py

Browse files
Files changed (1) hide show
  1. extract_climateset.py +39 -0
extract_climateset.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import snapshot_download
2
+ import tarfile
3
+ from glob import glob
4
+ import os
5
+
6
+ # Path of the directory where the data will be downloaded in your local machine
7
+ local_directory = 'LOCAL_DIRECTORY'
8
+
9
+ # TODO : Token to access the private repository, delete when the repository will be public
10
+ access_token = "ACCESS_TOKEN"
11
+
12
+ repo_id = "climateset/causalpaca"
13
+ repo_type = "dataset"
14
+
15
+ # Uncomment the snapshot_download(...) function call to download the entire dataset from the HuggingFace Repository. This takes while.
16
+
17
+ print("Downloading the ClimateSet HuggingFace Repository...")
18
+ #snapshot_download(repo_id=repo_id, repo_type=repo_type, local_dir=local_directory, local_dir_use_symlinks=False, token=access_token)
19
+ print("Done.")
20
+
21
+ print("Extracting the compressed input data...")
22
+ input_files = glob(local_directory + "/inputs/*.tar.gz")
23
+ for input_file in input_files:
24
+ #tar = tarfile.open(input_file)
25
+ #tar.extractall(path=local_directory + "/inputs/")
26
+ #tar.close()
27
+ os.remove(input_file)
28
+ print("Done.")
29
+
30
+ print("Extracting the compressed output data...")
31
+ output_files = glob(local_directory + "/outputs/*.tar.gz")
32
+ for output_file in output_files:
33
+ #tar = tarfile.open(output_file)
34
+ #tar.extractall(path=local_directory + "/outputs/")
35
+ #tar.close()
36
+ os.remove(output_file)
37
+ print("Done.")
38
+
39
+ print("Done. Finished downloading and extracting the Climateset data! :)")