I have 60 Excel files. Each files have 8 sheets. Sheets are same for each files but number of columns are different for each file.
I have come across different post
You can use your function read_excel_allsheets
like this:
read_excel_allsheets <- function(filename) {
sheets <- readxl::excel_sheets(filename)
x <- lapply(sheets, function(X) readxl::read_excel(filename, sheet = X))
names(x) <- sheets
x
}
files <- list.files(path = "/directory/in/question/",
pattern = "*.xlsx",
full.names = TRUE)
out <- lapply(files, read_excel_allsheets)
names(out) <- basename(files)