【问题标题】:Extract Google Drive multi zip from Google colab notebook从 Google colab 笔记本中提取 Google Drive multi zip
【发布时间】:2019-12-17 07:49:14
【问题描述】:

我在 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.

两者都不起作用。

【问题讨论】:

  • !7z x train.zip.001 这个工作
  • 重命名文件后尝试。我经常使用的一个衬里是 !unzip "file.zip" -d "target-dir"

标签: python zip google-colaboratory unzip zipfile


【解决方案1】:

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

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

可能对你有用...

【讨论】:

    猜你喜欢
    • 2022-09-27
    • 1970-01-01
    • 1970-01-01
    • 2020-10-01
    • 1970-01-01
    • 2023-02-22
    • 2021-08-14
    • 1970-01-01
    • 2018-09-14
    相关资源
    最近更新 更多