从Google colab笔记本中提取Google Drive多压缩文件

时间:2019-08-09 14:34:02

标签: python zip google-colaboratory unzip zipfile

我在Google云端硬盘上有一系列的zip文件:'train.zip.001''train.zip.002''train.zip.003''train.zip.004''train.zip.005'。它们每个都是8GB。我不知道如何提取它们。

我尝试过:

    with Zipfile.ZipFile('train.zip','r') as zipob:
      zipob.extractall('train2')

    with Zipfile.ZipFile('train.zip.001','r') as zipob:
      zipob.extractall('train2')

他们给出了两个不同的错误:


BadZipFile                                Traceback (most recent call last)
<ipython-input-32-ebacbe394be2> in <module>()
----> 1 with zipfile.ZipFile('train.zip','r') as zipob:
      2   zipob.extractall('train2')

1 frames
/usr/lib/python3.6/zipfile.py in _RealGetContents(self)
   1196             raise BadZipFile("File is not a zip file")
   1197         if not endrec:
-> 1198             raise BadZipFile("File is not a zip file")
   1199         if self.debug > 1:
   1200             print(endrec)

BadZipFile: File is not a zip file
!unzip train.zip.001
Archive:  train.zip.001
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of train.zip.001 or
        train.zip.001.zip, and cannot find train.zip.001.ZIP, period.

两者都不起作用。

1 个答案:

答案 0 :(得分:0)

我试过提取 64 个 7z 文件,如 7z.001、7z.002 文件,... 为了解决它,我使用了:

!7z x "/content/drive/My Drive/GitHub/DATA/images.7z.001" -tsplit

也许对你有用...

相关问题