我正在编写一个脚本,将来自许多不同excel电子表格的表格组合成一个spreadhseet。我采取的步骤:
1)创建所有感兴趣的Excel电子表格的列表 2)为每个电子表格 - 检查相关的"表格"在那个电子表格中 3)......最终(尚未在此阶段)...从每个工作表中选择相关的单元格并将它们导入到单个数据框中(因为它们应该都具有相同的标题......)
我必须进入第2阶段,因为我收到的错误似乎表明该脚本正在尝试打开一个不存在的文件。
# create a list of all folders at the next level that contain all of the
excel spreadsheets
cluster_folders <- dir(path = in_path, pattern = "GLU", all.files = FALSE,
full.names = FALSE, recursive = FALSE,
ignore.case = FALSE, include.dirs = FALSE, no.. =
FALSE)
all_plots <- list()
# iteratively loop through them
for(fld in cluster_folders){
# create a list of all excel files
plots <- list.files(path = file.path(in_path, fld), pattern = "GLU", all.files = FALSE,
full.names = TRUE, recursive = FALSE, ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)
all_plots <- append(all_plots, plots)
}
print(all_plots)
# for each excel file perform a check that ensures each excel spreadsheet
has the a sheet that contains stem measurements
for(plot in all_plots){
# file name is
print(plot)
shts <- excel_sheets(path = plot)
#print(shts)
sht_num <- match('Field Form - F5b - Trees',shts)
# now we navigate to that sheet and check that all the information is
there
#data <- read.xls(plot, sheet="Field Form - F5b - Trees")
}
此脚本适用于除2之外的所有文件。
我收到的错误消息是:评估错误:zip文件&#39; C:/ ..... / Survey / GLU0223537 /〜$ GLU0223537 plot 1.xlsx&#39;无法打开。
...当我查看此文件夹时,不存在此类文件。 1)它曾经然后我将它重新保存到.xls(因为所有正常工作的文件都是.xls)和2)我完全删除了它。
任何建议表示赞赏。提前谢谢
贝基