Skip to content

Instantly share code, notes, and snippets.

@edavidaja
Created May 28, 2019 22:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edavidaja/f97ec41afda1bb04d7b01db3d04b28bb to your computer and use it in GitHub Desktop.
Save edavidaja/f97ec41afda1bb04d7b01db3d04b28bb to your computer and use it in GitHub Desktop.
convert legacy xls files to xlsx files
library(purrr)
xls_to_xlsx <- function(file) {
if (fs::path_ext(file) != "xls") {
stop("file must have extension xls")
}
sheets <- readxl::excel_sheets(file)
insheets <- map(sheets, ~readxl::read_excel(file, .x, col_names = FALSE))
insheets <- set_names(insheets, sheets)
outfile <- fs::path_ext_set(file, "xlsx")
writexl::write_xlsx(insheets, outfile, col_names = FALSE)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment