我正在为13 K pdf文件做循环,它在其中读取,预处理文本,查找相似之处并以txt形式写入。但是,当我在760个pdf文件后运行for循环时,R会话中止。可能是什么原因?
memory_limit()
,这也不是问题。 Thumbs.db
,但是再次出现相同的问题。 Error in file(file, ifelse(append, "a", "w")) : can not open the connection. In addition: There are 50 warnings() and R session aborted.
folder_path <- "C: ...."
## get vector with all pdf names
pdf_folder <- list.files(folder.path)
## for loop over all pdf documents
for(s in 1:length(pdf_folder)){
# for(s in 1:2){
tryCatch({
## choose one pdf document from vector of strings
pdf_document_name <- pdf_folder[s]
## read pdf_document pdf into data.frame
pdf <- read_pdf(paste0(folder_path,"/",pdf_document_name))
print(s)
rm(pdf)
## first end trycatch block
}, error = function(e){print(paste("Error: PDF Document not used: ",pdf_document_name, sep =""))}
) ## end of trycatch
} ## end of for loop
# Error:
Error in file(file, ifelse(append, "a", "w")) : can not open the connection. In addition: There are 50 warnings()
预期结果是读取,预处理folder.path中的所有pdf文档。