A utility function to retrieve the file information of a filename, path, or URL.
Value
For get_info()
, a list is return with the following slots
input
file extension or information used to identify the possible file formatformat
file format, seeformat
argument ofimport()
type
"import" (supported by default); "suggest" (supported by suggested packages, seeinstall_formats()
); "enhance" and "known " are not directly supported;NA
is unsupportedformat_name
name of the formatimport_function
What function is used to import this fileexport_function
What function is used to export this filefile
file
For get_ext()
, just input
(usually file extension) is returned; retained for backward compatibility.
Examples
get_info("starwars.xlsx")
#> $input
#> [1] "xlsx"
#>
#> $format
#> [1] "xlsx"
#>
#> $type
#> [1] "import"
#>
#> $format_name
#> [1] "Excel"
#>
#> $import_function
#> [1] "readxl::read_xlsx"
#>
#> $export_function
#> [1] "writexl::write_xlsx"
#>
#> $file
#> [1] "starwars.xlsx"
#>
get_info("starwars.ods")
#> $input
#> [1] "ods"
#>
#> $format
#> [1] "ods"
#>
#> $type
#> [1] "suggest"
#>
#> $format_name
#> [1] "OpenDocument Spreadsheet"
#>
#> $import_function
#> [1] "readODS::read_ods"
#>
#> $export_function
#> [1] "readODS::write_ods"
#>
#> $file
#> [1] "starwars.ods"
#>
get_info("https://github.com/ropensci/readODS/raw/v2.1/starwars.ods")
#> $input
#> [1] "ods"
#>
#> $format
#> [1] "ods"
#>
#> $type
#> [1] "suggest"
#>
#> $format_name
#> [1] "OpenDocument Spreadsheet"
#>
#> $import_function
#> [1] "readODS::read_ods"
#>
#> $export_function
#> [1] "readODS::write_ods"
#>
#> $file
#> [1] "https://github.com/ropensci/readODS/raw/v2.1/starwars.ods"
#>
get_info("~/duran_duran_rio.mp3")
#> $input
#> [1] "mp3"
#>
#> $format
#> [1] NA
#>
#> $type
#> [1] NA
#>
#> $format_name
#> [1] NA
#>
#> $import_function
#> [1] NA
#>
#> $export_function
#> [1] NA
#>
#> $file
#> [1] "~/duran_duran_rio.mp3"
#>
get_ext("clipboard") ## "clipboard"
#> [1] "clipboard"
get_ext("https://github.com/ropensci/readODS/raw/v2.1/starwars.ods")
#> [1] "ods"