我想在线下载excel文件并只读取包含单词“ORD”的行。从Excel文件在线导入数据
fileUrl <-("http://www.hkexnews.hk/reports/sharerepur/documents/SRRPT20151211.xls")
x <- getURLContent(fileUrl)
out <- read.table(fileUrl,x)
我使用GetUrlContent但在过程的早期阶段收到一个错误:
警告消息:
1: In read.table(fileUrl, x) : line 1 appears to contain embedded nulls 2: In read.table(fileUrl, x) : line 2 appears to contain embedded nulls 3: In read.table(fileUrl, x) : line 3 appears to contain embedded nulls 4: In read.table(fileUrl, x) : line 4 appears to contain embedded nulls 5: In read.table(fileUrl, x) : line 5 appears to contain embedded nulls 6: In if (!header) rlabp <- FALSE : the condition has length > 1 and only the first element will be used 7: In if (header) { : the condition has length > 1 and only the first element will be used 8: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : embedded nul(s) found in input
表 “走出去” 出来几乎不可读。有谁知道如何精确读取特定的行,而不是导入整个文件的风险得到错误行?
喜添,非常感谢你。我可以检索文件没有任何问题。但问题是该文件不完全是数据框。它包含一些描述性的信息,直到某一行,然后有一个数据帧。 – Pino
@Pino我更新了我的答案。使用'pattern'跳过你不想要的行。 –