Closed chainsawriot closed 12 months ago
@chainsawriot, That's a good question, and I understand the complexity you're asking about.
My main goal was the slight extension of what is done in tools::file_ext()
. But, if we had something that could detect the real file format, from your example, returning html
for an htm
file extension, I see a benefit of that, too. I think that your idea to normalize file extension with expected file format ("htm" becomes "html", "yml" becomes "yaml") would be more beneficial.
TODO
get_info()
that queries the internal data to get complete information (ext
, format
, format_name
, input_function
, export_function
) of file
input get_ext()
by wrapping get_info()
, something like get_info(file)$ext
.Need to coordinate with #313 #351
https://github.com/gesistsa/rio/blob/f0198a386db58335adee1a435cc39c5eba6d9103/R/utils.R#L11-L30
The function actually is not actually doing what #169 and the documentation ("A characters string containing a file type recognized by rio.") said and what @billdenney requested. Actually, "file type" is confusing. Let's call this
format
(as in the argument ofimport
). The main issue is thatget_type()
is just running insideget_ext()
without assigning it to anything.To give an example:
Created on 2023-09-07 with reprex v2.0.2
It is almost the same as
tools::file_ext
, just with an additional care of URL.Also a consequence to this,
get_ext("twotables.htm")
actually return "htm". And therefore, this bunch of check forhtml
wont workhttps://github.com/gesistsa/rio/blob/f0198a386db58335adee1a435cc39c5eba6d9103/R/import_list.R#L115-L130
Created on 2023-09-08 with reprex v2.0.2
May I ask you @billdenney : What did you really want in the first place? You want it to be like
tools::file_ext()
(I get confused by the function nameget_ext()
) or to returnformat
.