zipfile извлекает все сообщение об ошибке «BadZipFile: Bad CRC-32 для файла» - PullRequest
2 голосов
/ 19 мая 2019

Это файл, который я пытаюсь открыть

https://drive.google.com/file/d/1K2kDBTNXS2ikx9xKmi2Fy0Wsc5u_Lls0/view

Он описан здесь

https://github.com/armancohan/long-summarization

После того, как я добавилфайл на моем диске Google, это код, который я пытаюсь использовать, чтобы открыть его.

from google.colab import drive
drive.mount('/content/gdrive')
import zipfile

zip_ref = zipfile.ZipFile('/content/gdrive/My Drive/arxiv-release.zip', 'r')
zip_ref.extractall('arxiv-release')
zip_ref.close()

Это ошибка, которая возникает

---------------------------------------------------------------------------
BadZipFile                                Traceback (most recent call last)
<ipython-input-9-9965160388a1> in <module>()
      1 
----> 2 zip_ref.extractall('arxiv-release')
      3 zip_ref.close()

5 frames
/usr/lib/python3.6/zipfile.py in extractall(self, path, members, pwd)
   1522 
   1523         for zipinfo in members:
-> 1524             self._extract_member(zipinfo, path, pwd)
   1525 
   1526     @classmethod

/usr/lib/python3.6/zipfile.py in _extract_member(self, member, targetpath, pwd)
   1577         with self.open(member, pwd=pwd) as source, \
   1578              open(targetpath, "wb") as target:
-> 1579             shutil.copyfileobj(source, target)
   1580 
   1581         return targetpath

/usr/lib/python3.6/shutil.py in copyfileobj(fsrc, fdst, length)
     77     """copy data from file-like object fsrc to file-like object fdst"""
     78     while 1:
---> 79         buf = fsrc.read(length)
     80         if not buf:
     81             break

/usr/lib/python3.6/zipfile.py in read(self, n)
    870         self._offset = 0
    871         while n > 0 and not self._eof:
--> 872             data = self._read1(n)
    873             if n < len(data):
    874                 self._readbuffer = data

/usr/lib/python3.6/zipfile.py in _read1(self, n)
    960         if self._left <= 0:
    961             self._eof = True
--> 962         self._update_crc(data)
    963         return data
    964 

/usr/lib/python3.6/zipfile.py in _update_crc(self, newdata)
    888         # Check the CRC if we're at the end of the file
    889         if self._eof and self._running_crc != self._expected_crc:
--> 890             raise BadZipFile("Bad CRC-32 for file %r" % self.name)
    891 
    892     def read1(self, n):

BadZipFile: Bad CRC-32 for file 'arxiv-release/train.txt'
...