How do I unzip a zip file in R? - zip

unzip("fasta.gz")
Warning message:
In unzip("fasta.gz") : error 1 in extracting from zip file
I am trying to unzip a gz file but I am getting an error. How do I fix this?

Related

No such file or directory in pyinstaller

When I try to run a .exe file made with python, I get the following message:
No such file or directory:
'C:\Users\[myUsername]\AppData\Local\Temp\_MEI171122\tldextract\.tld_set'
What should I do?

Unziping zipped file in google colab

i ma trying to unzip a zip file in google colab and i get this Error
Archive: object_detection.zip
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 object_detection.zip or
object_detection.zip.zip, and cannot find object_detection.zip.ZIP, period.
from google.colab import drive
drive.mount('/content/drive')
!cp '/content/drive/My Drive/slim.zip' slim.zip
!unzip object_detection.zip
i already uploded my zip files on the drive
Probable reason could be your zip file is corrupt.. may be you are not using proper link.. try downloading the file and then uploading on colab.. it should work.
I had the same problem and it was because I had not uploaded the file completely

"No such file or directory" - but the file I want to open is right there

I'm using a little loader.py file, that opens a .gz file:
---> 38 f = gzip.open('mnist.pkl.gz', 'rb')
But I'm getting this error:
FileNotFoundError: [Errno 2] No such file or directory: 'mnist.pkl.gz'
I had this problem when loading the loader.py file as well, but I fixed it by doing:
sys.path
sys.path.append -- and adding the right folder to the directory.
But the .gz file is in the same folder, so I don't understand how it can find one but not the other?
I am very new to Python so please be gentle (done loads of Matlab but I'm trying to work through some machine learning code).

cant unzip file in GCP jupyterlab notebook: 'End-of-central-directory signature not found.'

I am running python 3
I am trying to unzip my train.zip dataset on a GCP notebook instance, however whenever I try to I get a various error:
First I tried:
import os
from zipfile import ZipFile
os.path.exists('/home/jupyter/kerasProject/original_dataset/train.zip')
True
zip_file = ZipFile('/home/jupyter/kerasProject/original_dataset/train.zip')
Error:
BadZipFile: File is not a zip file
Then I tried:
!unzip '/home/jupyter/kerasProject/original_dataset/train.zip'
Error:
Archive: /home/jupyter/kerasProject/original_dataset/train.zip
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 /home/jupyter/kerasProject/original_dataset/train.zip or
/home/jupyter/kerasProject/original_dataset/train.zip.zip, and cannot find /home/jupyter/kerasProject/original_dataset/train.zip.ZIP, period.
For some reason in both cases it does not recogise the file as a .zip file, I tried reuploading it but it doesn't help, I can unzip it on my mac no problems so I don't think it can be corrupt, what have I done wrong?

Handling winrar archive files in python

I'm using Python 3.6 and I want to know if there is a way to handle winrar (.Z extension) files in Python. I have used the following code:
zip_ref = zipfile.ZipFile('POTCAR.z','r') #POTCAR.z is the winrar archive file
zip_ref.extract('folder to which I want to write')
zip_ref.close()
But I keep getting this error:
BadZipFile: File is not a zip file
What is the solution to this? Is there any other library for handling such files?
I remember that I have used zLib for extracting winrar archives.
You could use gzip:
gzip_file = gzip.open('Potcar.z') # use gzip.open instead of builtin open function
file_content = gzip_file.read()
and to save it (if it is a text file - since you didnt specify):
file = open(“my_file.txt”,”w”)
file.write(file_content)
file.close()

Resources