Код: Выделить всё
import tarfile
# Specify the path to your .tgz file
tgz_file_path = '/kaggle/input/grb-dataset/pt_files.tgz'
# Directory to extract files into
output_folder = '/kaggle/working/pt_files'
# Create the output folder if it doesn't exist
if not os.path.exists(output_folder):
os.makedirs(output_folder)
# Open the .tgz file and extract its contents
with tarfile.open(tgz_file_path, 'r:gz') as tar:
tar.extractall(path=output_folder)
# Count the number of extracted files
num_files = len([name for name in os.listdir(output_folder) if os.path.isfile(os.path.join(output_folder, name))])
print(f"Files extracted to {output_folder}")
print(f"Number of files extracted: {num_files}")
Код: Выделить всё
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Cell In[4], line 16
14 # Open the .tgz file and extract its contents
15 with tarfile.open(tgz_file_path, 'r:gz') as tar:
---> 16 tar.extractall(path=output_folder)
18 # Count the number of extracted files
19 num_files = len([name for name in os.listdir(output_folder) if os.path.isfile(os.path.join(output_folder, name))])
File /opt/conda/lib/python3.10/tarfile.py:2264, in TarFile.extractall(self, path, members, numeric_owner, filter)
2259 if tarinfo.isdir():
2260 # For directories, delay setting attributes until later,
2261 # since permissions can interfere with extraction and
2262 # extracting contents can reset mtime.
2263 directories.append(tarinfo)
-> 2264 self._extract_one(tarinfo, path, set_attrs=not tarinfo.isdir(),
2265 numeric_owner=numeric_owner)
2267 # Reverse sort directories.
2268 directories.sort(key=lambda a: a.name, reverse=True)
File /opt/conda/lib/python3.10/tarfile.py:2331, in TarFile._extract_one(self, tarinfo, path, set_attrs, numeric_owner)
2327 self._extract_member(tarinfo, os.path.join(path, tarinfo.name),
2328 set_attrs=set_attrs,
2329 numeric_owner=numeric_owner)
2330 except OSError as e:
-> 2331 self._handle_fatal_error(e)
2332 except ExtractError as e:
2333 self._handle_nonfatal_error(e)
File /opt/conda/lib/python3.10/tarfile.py:2327, in TarFile._extract_one(self, tarinfo, path, set_attrs, numeric_owner)
2324 self._check("r")
2326 try:
-> 2327 self._extract_member(tarinfo, os.path.join(path, tarinfo.name),
2328 set_attrs=set_attrs,
2329 numeric_owner=numeric_owner)
2330 except OSError as e:
2331 self._handle_fatal_error(e)
File /opt/conda/lib/python3.10/tarfile.py:2410, in TarFile._extract_member(self, tarinfo, targetpath, set_attrs, numeric_owner)
2407 self._dbg(1, tarinfo.name)
2409 if tarinfo.isreg():
-> 2410 self.makefile(tarinfo, targetpath)
2411 elif tarinfo.isdir():
2412 self.makedir(tarinfo, targetpath)
File /opt/conda/lib/python3.10/tarfile.py:2455, in TarFile.makefile(self, tarinfo, targetpath)
2453 source.seek(tarinfo.offset_data)
2454 bufsize = self.copybufsize
-> 2455 with bltn_open(targetpath, "wb") as target:
2456 if tarinfo.sparse is not None:
2457 for offset, size in tarinfo.sparse:
OSError: [Errno 28] No space left on device: '/kaggle/working/pt_files/pt_files/grb3.2e+48_3.2e-02_1.0e-02_3.2e-05_1.3e+06.pt'
Код: Выделить всё
Filesystem Size Used Avail Use% Mounted on
/dev/loop1 20G 5.2G 15G 27% /kaggle/working
Буду очень признателен за любую помощь. Спасибо!
РЕДАКТИРОВАТЬ: Размер папки, из которой я создал сжатый файл .tgz, составляет ~15 ГБ, поэтому не должно быть быть ли какие-либо проблемы с распакованным файлом, превышающим мой лимит хранения.
Подробнее здесь: https://stackoverflow.com/questions/791 ... -on-device