yuxuanw8 commited on
Commit
b35c324
·
verified ·
1 Parent(s): 5a554db

Update BigEarthNet.py

Browse files
Files changed (1) hide show
  1. BigEarthNet.py +16 -0
BigEarthNet.py CHANGED
@@ -186,6 +186,22 @@ class BigEarthNetDataset(datasets.GeneratorBasedBuilder):
186
  print("Downloading Finished")
187
  print(f"downloaded files: {downloaded_files}")
188
  combined_file = os.path.join(dl_manager.download_config.cache_dir, "combined.tar.gz")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  print(f"copying files to {combined_file}")
190
  with open(combined_file, 'wb') as outfile:
191
  counter = 0
 
186
  print("Downloading Finished")
187
  print(f"downloaded files: {downloaded_files}")
188
  combined_file = os.path.join(dl_manager.download_config.cache_dir, "combined.tar.gz")
189
+ target_dir = os.path.dirname(combined_file)
190
+ os.makedirs(target_dir, exist_ok=True) # Create only the directory
191
+
192
+ print(f"Target directory: {target_dir}")
193
+ try:
194
+ with open(combined_file, 'wb') as outfile:
195
+ counter = 0
196
+ for part_file in downloaded_files:
197
+ print(f"copying {counter}-th file: {part_file}")
198
+ with open(part_file, 'rb') as infile:
199
+ shutil.copyfileobj(infile, outfile)
200
+ counter += 1
201
+ except Exception as e:
202
+ print(f"Error during file operations: {str(e)}")
203
+ print(f"File exists: {os.path.exists(combined_file)}")
204
+ print(f"Is directory: {os.path.isdir(combined_file)}")
205
  print(f"copying files to {combined_file}")
206
  with open(combined_file, 'wb') as outfile:
207
  counter = 0