'How to fix 'Input/output error' while extracting zipfile?
I am working with a 150GB+ zipfile of dicom images. I am trying to extract some of these by their filenames.
I am working on google collab python 3 interpreter and use zipfile module along with ZipFile.extractall()
method on a list of filenames of length 500 (ex : ['stage_1_train_images/ID_53ff71bc4.dcm', 'stage_1_train_images/ID_001bb2c00.dcm',etc...]) :
.
Here's my code :
from zipfile import ZipFile
with ZipFile(src, 'r') as zipObj:
zipObj.extractall(members = ids, path = '/content/drive/My Drive/RSNA IH DETECTION CHALLENGE/DICOM') #ids is my file list
I got an error message :
"OSError: [Errno 5] Input/output error", related to a message in read(self, n) : "727 "Close the writing handle before trying to read.")"
I tried to close the file and re-open it, tried to extract with the .extract() method several times and always got the same err message.
I first attempted to use fuse zip along with shutil.copyfile()
but it failed to...
Do you know what's causing this error message and a possible way to fix it?
Solution 1:[1]
I fixed this problem with re-downloading the original file. My version, stored on Google Drive was probably corrupted. Now fuse-zip works as well as ZipFile methods !
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | LucMat14 |