I've got a lot of files in a folder, many of them are empty and others with data inside.
What I'm trying to do is this:
#Load all data in a list
file_all <- list.files(file.path(getwd(), "testall"), pattern = "\\.txt$")
Using this list, I'm trying to skip empty files using the method explained by @nrussell How to skip empty files when importing text files in R?
library(plyr)
df_list <- lapply(files, function(x) {
if (!file.size(x) == 0) {
list.files(x)
}
})
And (not empty files)
df_list2 <- lapply(files, function(x) {
if (file.size(x) == 0) {
list.files(x)
}
})
The difference between @nrussell and mine is that I want to create a list of empty files and another list with not empty files. I'd like to know how many files are empty and how many are not empty.