【发布时间】:2019-08-01 07:15:04
【问题描述】:
我正在尝试加载以下.xls 文件。
链接到.xls 文件。
https://ufile.io/5vy4g
我正在使用一个函数(我已经减少了必要性。
product <- c("/saltsnck")
gettables <- function(year, weeks, product){
prod <- read_excel("E:/DIR/prod_saltsnck.xls")
}
Map(gettables, year, weeks, product)
DIR 需要更改为文件下载到的DIR。该文件名为prod_saltsnck.xls。
当我尝试加载文件时,出现以下错误:
Error in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim, :
Failed to open E:DIR/prod_saltsnck.xls
在线查看时,一些建议指出工作表名称不正确,但该文件与我加载到 R 中的许多其他类似文件相同。唯一的区别是它是不同的产品。
当我直接尝试在函数外部读取文件时,我得到了同样的错误:
prod <- read_excel("E:/DIR/prod_saltsnck.xls")
我似乎无法在 excel 文件中找到问题,之前加载的所有 30 个产品 excel 表都可以正常工作。
编辑:
这是一个有效的 excel 文件,但可能已损坏?我可以毫无问题地使用excel打开excel文件。
编辑 2:
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252 LC_MONETARY=Spanish_Spain.1252
[4] LC_NUMERIC=C LC_TIME=Spanish_Spain.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] reshape_0.8.7 bindrcpp_0.2.2 forcats_0.3.0 stringr_1.3.1 purrr_0.2.5 readr_1.1.1
[7] tidyr_0.8.1 tibble_1.4.2 ggplot2_3.0.0 tidyverse_1.2.1 plyr_1.8.4 readxl_1.1.0
[13] dplyr_0.7.6 magrittr_1.5
【问题讨论】:
-
是的,该文件存在,我附上了当我尝试使用 R 导入数据集函数加载它时收到的错误的屏幕截图。
-
你使用哪个包?我猜是readxl?您是否尝试更新软件包?
-
是的包是`library(readxl)` 我使用的是版本
readxl_1.1.0 -
试试 readr::read_tsv
-
我收到此错误:
> prod <- read_tsv("E:/IRI Data/Academic Dataset External/parsed stub files/prod_saltsnck.xls") Parsed with column specification: cols( ``<d0><cf><U+0871><e1>`` = col_character(), col_character(), A = col_character() ) Error in read_tokens_(data, tokenizer, col_specs, col_names, locale_, : Evaluation error: Column 2 must be named.