# NOT RUN {
unlink(dir(tempdir(), full.names = TRUE))
data(mtcars)
mt_german <- mtcars
rownames(mt_german)[1] <- "Mazda R\u00f64"
names(mt_german)[1] <- "mg\u00dc"
for (i in 1:10) {
f <- file.path(tempdir(), paste0("f", i, ".csv"))
write.csv(mtcars[1:5, TRUE], file = f)
f <- file.path(tempdir(), paste0("f", i, "_german.csv"))
write.csv2(mt_german[1:7, TRUE], file = f, fileEncoding = "Latin1")
}
#% read
bulk <- bulk_read_csv(tempdir())
print(mtime <- file.info(list.files(tempdir(), full.names = TRUE))["mtime"])
bulk[["f2"]][3, 5] <- bulk[["f2"]][3, 5] + 2
Sys.sleep(2) # make sure the mtimes would change
result <- bulk_write_csv(bulk)
print(new_times <- file.info(dir(tempdir(), full.names = TRUE))["mtime"])
index_change <- grep("f2\\.csv", rownames(mtime))
if (requireNamespace("digest", quietly = TRUE)) {
only_f2_changed <- all((mtime == new_times)[-c(index_change)]) &&
(mtime < new_times)[c(index_change)]
RUnit::checkTrue(only_f2_changed)
} else {
RUnit::checkTrue(all(mtime < new_times))
}
# }
Run the code above in your browser using DataLab