Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

r function unzip error 1 in extracting from zip file

Tags:

Environment: Windows 7 OS RStudio Version 0.99.491

I have been programming in R for about 4 months via the Coursera Data Science curriculum, but I have NEVER been successful in using the unzip function.

I've looked at the forums for hours for potential solutions, syntax problems, undefined arguments, etc., but to no avail. I eventually unzip the contents manually and proceed with the assignment, but I am tired of not knowing why it is not working.

Here are a few examples of the error:

fileName <- "StormData.zip"

unzip(fileName, exdir = mainDir,subDir)

Warning message: In unzip(fileName, exdir = mainDir, subDir) : error 1 in extracting from zip file

unzip(fileName)

Warning message: In unzip(fileName) : error 1 in extracting from zip file

unzip(fileName, "stormdata.csv")

Warning message: In unzip(fileName, "stormdata.csv") : error 1 in extracting from zip file

unzip(fileName, "stormdata.csv", list = TRUE)

Error in unzip(fileName, "stormdata.csv", list = TRUE) : zip file 'StormData.zip' cannot be opened

Any suggestions would be greatly appreciated.

like image 526
Richmodo Avatar asked May 14 '16 00:05

Richmodo


People also ask

How do I fix an unzip error?

Usually the easiest way to resolve it is to simply re-download the file if it was corrupted, or if the file was incomplete. Nonetheless sometimes you have to repair the file, or use a different zip app.

How do I unzip a zip file in R?

To zip file, use zip(). To unzip the file, use unzip(). To tar the file, use tar(). To untar the file, use untar().

Why can't I unpack a zip file?

Zip files may refuse to open if they are not properly downloaded. Also, incomplete downloads occur when files get stuck due to issues like bad internet connection, inconsistency in network connection, all of which can cause transfer errors, affect your Zip files, and make them unable to open.


1 Answers

I was getting the same error.

I changed the path --

from :

uzp <- "C:\\Users\\Sharvari\\Downloads\\rprog%2Fdata%2Fspecdata"

to

uzp <- "C:\\Users\\Sharvari\\Downloads\\rprog%2Fdata%2Fspecdata.zip"

and it works fine!

setwd("C:\\Users\\Sharvari\\Downloads")

uzp <- "C:\\Users\\Sharvari\\Downloads\\rprog%2Fdata%2Fspecdata.zip"

unzip(uzp, exdir = "C:\\Users\\Sharvari\\Desktop\\specdata")
like image 179
Sharvari Gc Avatar answered Oct 12 '22 22:10

Sharvari Gc