@@ -82,19 +82,25 @@ import_list <- function(file, setclass = getOption("rio.import.class", "data.fra
8282}
8383
8484.read_file_as_list <- function(file, which, setclass, rbind, rbind_label, ...) {
85+ ## respect the `format` argument, if given
86+ if ("format" %in% ...names()) {
87+ format <- list(...)[["format"]]
88+ } else {
89+ format <- get_info(file)$format
90+ }
8591 if (R.utils::isUrl(file)) {
8692 file <- remote_to_local(file)
8793 }
88- if (get_info(file)$ format == "rdata") {
94+ if (format == "rdata") {
8995 return(.import.rio_rdata(file = file, .return_everything = TRUE, ...))
9096 }
9197 archive_format <- find_compress(file)
92- if (!get_info(file)$ format %in% c("html", "xlsx", "xls", "ods", "fods") && !archive_format$compress %in% c("zip", "tar", "tar.gz", "tar.bz2")) {
98+ if (!format %in% c("html", "xlsx", "xls", "ods", "fods") && !archive_format$compress %in% c("zip", "tar", "tar.gz", "tar.bz2")) {
9399 which <- 1
94100 whichnames <- NULL
95101 }
96102 ## getting list of `whichnames`
97- if (get_info(file)$ format == "html") {
103+ if (format == "html") {
98104 .check_pkg_availability("xml2")
99105 tables <- xml2::xml_find_all(xml2::read_html(unclass(file)), ".//table")
100106 if (missing(which)) {
@@ -106,10 +112,10 @@ import_list <- function(file, setclass = getOption("rio.import.class", "data.fra
106112 )
107113 names(which) <- whichnames
108114 }
109- if (get_info(file)$ format %in% c("xls", "xlsx", "ods", "fods")) {
115+ if (format %in% c("xls", "xlsx", "ods", "fods")) {
110116 ## .check_pkg_availability("readxl")
111117 sheet_func <- readxl::excel_sheets
112- if (get_info(file)$ format %in% c("ods", "fods")) {
118+ if (format %in% c("ods", "fods")) {
113119 .check_pkg_availability("readODS")
114120 sheet_func <- readODS::list_ods_sheets
115121 }
0 commit comments