[英]Error in gzfile(file, “rb”) : invalid 'description' argument Called from: gzfile(file, “rb”)
我在嘗試使用我制作的配置文件映射某些列時遇到了一個函數問題。 我正在運行該功能,但出現錯誤:
Error in gzfile(file, "rb") : invalid 'description' argument Called from: gzfile(file, "rb")
我在網上看過,包括堆棧溢出,但沒有得到正確的答案。 你能幫忙嗎? 我已經使該功能在另一台機器上運行良好,但是當我嘗試將工作部署到個人筆記本電腦上時,似乎出現了此錯誤。
這是我在Mac中嘗試做的事情:
思考路徑設置為:
data_import_list <- list(list(data_path = "Users/gb/Rprojects/data/data.csv",
config_path = "Users/gb/Rprojects/lgt-config/inp/"))
然后我用功能閱讀
import_col_types <- function(config_path){
column_mapping <- readRDS(file.path(config_path, "column_mapping.rds"))
# get list of config files
config_file_list <- Sys.glob(paste0(config_path, "*.rds"))
}
實際上,這就是我使用上述功能閱讀的方式:
import_col_types(data_import_list)
在錯誤之前打印出file
。 檢查它是您所認為的。 我可以使用以下方式復制您的錯誤消息:
> gzfile(1,"rb")
Error in gzfile(1, "rb") : invalid 'description' argument
> gzfile(NA,"rb")
Error in gzfile(NA, "rb") : invalid 'description' argument
> gzfile(NULL,"rb")
Error in gzfile(NULL, "rb") : invalid 'description' argument
但不是:
> gzfile("nonexist","rb")
Error in gzfile("nonexist", "rb") : cannot open the connection
In addition: Warning message:
In gzfile("nonexist", "rb") :
cannot open compressed file 'nonexist', probable reason 'No such file or directory'
因此看來您的file
已損壞。 我們無法看到它是什么,因此您需要自己調試。 基本調試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.