R unzip error 1 function when extracting from a zip file

Environment: Windows 7 RStudio Version 0.99.491

I programmed R for 4 months through the Coursera Data Science curriculum, but NEVER was successful in using the decompress function.

I looked on the forums for hours for potential solutions, syntax problems, undefined arguments, etc., but to no avail. I, in the end, unzip the contents manually and get down to the task, but I'm tired of not knowing why it doesn't work.

Here are some examples of errors:

fileName <- "StormData.zip"

unzip(fileName, exdir = mainDir,subDir)

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

unzip(fileName)

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

unzip(fileName, "stormdata.csv")

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

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

Unpacking error (file_name, "stormdata.csv", list = TRUE): zip file 'StormData.zip' cannot be opened

Any suggestions would be greatly appreciated.

+7
r unzip
source share
5 answers

I also received error 1 when trying to unzip a zip file. The key point in my case was the conflict between the working directory and the zip file.

My business was:

  • My working directory was like "C: / Users / SCOTT / Desktop / Training"
  • While my zip file was in the folder "C: / Users / SCOTT / Desktop / Training / house_consumption_data"

When I tried to execute this:

  unzip("house_data.zip") 

Your file may be in a different folder.

+1
source share

I had the same problem as when downloading and unpacking the same file. And I had problems with unpacking in the past, and I decided to solve it this time too.

The file extension ended up being csv.bz2. And than this. Extract the bz2 file in R after solving my problem. After downloading the file, I was able to read it directly with

 stormdata <- read.csv("stormdata.zip") 

without using unzip.

+1
source share

I was getting the same error.

I changed the way -

from:

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

to

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

and it works great!

 setwd("C:\\Users\\Sharvari\\Downloads") uzp <- "C:\\Users\\Sharvari\\Downloads\\rprog%2Fdata%2Fspecdata.zip" unzip(uzp, exdir = "C:\\Users\\Sharvari\\Desktop\\specdata") 
+1
source share

change the format of the zip file, this error will appear during problems with the zip format, look at your zip file, which should be "rar", change it to "zip". The function works only for files of the "zip" format.

0
source share

This error appears when openXLS cannot open the specified file. This may be the wrong name, the wrong directory, or the file may be encrypted or password protected.

0
source share

All Articles