気Chiii
気Chiii

Reputation: 11

How to solve no file error when unzip files in R?

1. Problems I met

A very strange error occurred to me these days. I wrote a loop to extract hundreds of zip files in my disk. Things work good initially but it will stuck at some point and report an error message like:

> extractResult <- extract(zipDir="/home/rstudio/Nick/00.Viscosity Modeling/Data")
Extracting  1 / 383  batch:  F-171204-00040 --- *INVALID*
Extracting  2 / 383  batch:  F-171207-00005 --- *INVALID*
Extracting  3 / 383  batch:  F-171211-00005.1 --- *INVALID*
......
Extracting  56 / 383  batch:  F-180621-00039 --- *INVALID*
Extracting  57 / 383  batch:  F-180621-00043 --- :)

Error in unzip(zips, exdir = to_dir) : 
  cannot open file '/home/rstudio/Nick/00.Viscosity Modeling/Data/Extract/F-180625-00014/Material.csv': No such file or directory
In addition: Warning messages:

Then I try to unzip this file separately but this same error occurs and occurs. So I tried to unzip another file F-180621-00043.zip which was successfully unzipped, but the most weired thing is it cannot be exrtacted, same for all the zip files listed above:

    > unzip("/home/rstudio/Nick/00.Viscosity Modeling/Data/archive/F-180621-00043.zip"
           ,exdir="/home/rstudio/Nick/00.Viscosity Modeling/Data")

    Error in unzip("/home/rstudio/Nick/00.Viscosity Modeling/Data/archive/F-180621-00043.zip",  : 
       cannot open file '/home/rstudio/Nick/00.Viscosity Modeling/Data/F-180621-00043/Material.csv':
       No such file or directory

My first thought is these files are corrupted so I added the list attribute, but it looks they are ready to be unzipped:

    > unzip("/home/rstudio/Nick/00.Viscosity Modeling/Data/archive/F-180621-00043.zip"
           ,exdir="/home/rstudio/Nick/00.Viscosity Modeling/Data",list=T)

                             Name   Length                Date
    1 F-180621-00043/Material.csv     6486 2020-04-24 06:30:00
    2  F-180621-00043/Quality.csv      330 2020-04-24 06:30:00
    3   F-180621-00043/Sensor.csv 93801262 2020-04-24 06:30:00

2. So my question is:

  1. there are csv fils in my zip but R keeps reporting there is no such file, why?
  2. why those files are extracted normally in my loop but cannot be unzipped by one-line unzip function?

Can anybody help me sort this error?

Upvotes: 1

Views: 578

Answers (1)

気Chiii
気Chiii

Reputation: 11

Solved!!!

I forgot to mention that all of the work I was doing is based on R Server, i.e. I'm working on the cloud.

It seems our company only provided us a limited cloud space for RStudio, so this error has no relation with unzip or my zip files. The unzip will stop once my allocated server is unable to store any byte of files.

Hope this will help some other people met similar problems.

Upvotes: 0

Related Questions