【发布时间】:2019-12-13 00:12:02
【问题描述】:
我正在通过以下方式使用readr::read_lines_chunked:
if(!require(readr)) install.packages("readr", repos = "http://cran.us.r-project.org")
mytb <- NULL
read_lines_chunked(file="/tmp/huge.xml", chunk_size=10, callback = function(xml, pos) {
// extract values from xml into tmp
if (is.null(mytb)) {
users <- as_tibble(tmp)
} else {
users <- bind_rows(users, as_tibble(tmp))
}
})
但这不起作用,因为mytb 总是以null 结尾......你如何将结果累积到一个小标题中?
【问题讨论】:
-
这里的变量名很难理解——回调函数中的两个参数是
xml和pos,但是你不使用它们,并且之前没有声明tmp它被使用了。