Reading Excel: evaluation error with zip file '..file.xlsx' cannot be opened

canpoint picture canpoint · Jun 18, 2017 · Viewed 30.2k times · Source

I am using R with readxl package. I try to import an Excel file with the following command:

library(readxl)
city_codes <- read_excel("./data/file.xlsx", sheet = "city_codes")

It says it is a zip file and cannot be opened:

Error in sheets_fun(path) : 
Evaluation error: zip file './data/file.xlsx' cannot be opened.

Any ideas?

Answer

DHW picture DHW · Aug 28, 2018

I had this error, but for me, it was just that I had the sheet open in Excel while trying to read it into R. I guess the package wrongly perceives it as a zip file when it's trying to read it while Excel has partial ownership of it (and this blocks the read).