strptime(d,fmt)中的 R tm 包 readPDF 错误:输入字符串太长

R tm package readPDF error in strptime(d, fmt) : input string too long

我想使用 tm 包对 this website 上的文件进行文本挖掘。我正在使用以下代码将文件之一(即 abell.pdf)下载到我的工作目录并尝试存储内容:

library("tm")
url <- "https://baltimore2006to2010acsprofiles.files.wordpress.com/2014/07/abell.pdf"
filename <- "abell.pdf"
download.file(url = url, destfile = filename, method = "curl")

doc <- readPDF(control = list(text = "-layout"))(elem = list(uri = filename),
                                                 language = "en", id = "id1")

但我收到以下错误和警告:

Error in strptime(d, fmt) : input string is too long
In addition: Warning messages:
1: In grepl(re, lines) : input string 1 is invalid in this locale
2: In grepl(re, lines) : input string 2 is invalid in this locale

pdf 不是特别长(5 页,978 KB),我已经能够成功地使用 readPDF 功能在我的 Mac OSX 上读取其他 pdf 文件。我最想要的信息(2010 年人口普查的总人口)位于每个 pdf 的第一页,因此我尝试将 pdf 缩短到第一页,但我得到了相同的信息。

我是 tm 包的新手,所以如果我遗漏了一些明显的东西,我深表歉意。非常感谢任何帮助!

根据我读到的内容,此错误与 "readPDF" 函数尝试为您正在导入的文件制作元数据的方式有关。无论如何,您可以使用 "info" 选项更改元数据信息。例如,我通常通过以下方式(使用您的代码)修改命令来规避此错误:

doc <- readPDF(control = list(info="-f",text = "-layout"))(elem = list(uri = filename),language = "en", id = "id1")

添加 "info="-f"" 是唯一的变化。这并不是真正的 "fix" 问题,但它绕过了错误。干杯:)