diff --git a/NEWS.md b/NEWS.md index 4b3fcf7..aee7d7f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,12 @@ +# rio 1.1.1.999 (development) + +Bug fixes + +* Fix #430 Add back support for `.dat` + # rio 1.1.1 -Bus fixes +Bug fixes * Fix #425 for archive formats, the file extension of the input file is determined by the compressed file (like prior rio 1.1.0) diff --git a/R/import_methods.R b/R/import_methods.R index edc603f..66a0550 100644 --- a/R/import_methods.R +++ b/R/import_methods.R @@ -29,7 +29,7 @@ import_delim <- function(file, which = 1, sep = "auto", header = "auto", strings #' @export .import.rio_dat <- function(file, which = 1, ...) { - message(sprintf("Ambiguous file format ('.dat'), but attempting 'data.table::fread(\"%s\")'", file)) + message(sprintf("Ambiguous file format ('.dat'), but attempting 'data.table::fread(\"%s\")'\n", file)) import_delim(file = file, ...) } diff --git a/R/sysdata.rda b/R/sysdata.rda index c844261..3007435 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/README.md b/README.md index fa4d392..149cba6 100644 --- a/README.md +++ b/README.md @@ -126,52 +126,53 @@ install_formats() The full list of supported formats is below: -| Name | Extensions / “format” | Import Package | Export Package | Type | Note | -| :---------------------------------- | :---------------------------------- | :------------- | :------------- | :------ | :---------------------- | -| Archive files (handled by tar) | tar / tar.gz / tgz / tar.bz2 / tbz2 | utils | utils | Default | | -| Bzip2 | bz2 / bzip2 | base | base | Default | | -| Gzip | gz / gzip | base | base | Default | | -| Zip files | zip | utils | utils | Default | | -| CSVY (CSV + YAML metadata header) | csvy | data.table | data.table | Default | | -| Comma-separated data | csv | data.table | data.table | Default | | -| Comma-separated data (European) | csv2 | data.table | data.table | Default | | -| Data Interchange Format | dif | utils | | Default | | -| Epiinfo | epiinfo / rec | foreign | | Default | | -| Excel | excel / xlsx | readxl | writexl | Default | | -| Excel (Legacy) | xls | readxl | | Default | | -| Fixed-width format data | fwf | readr | utils | Default | | -| Fortran data | fortran | utils | | Default | No recognized extension | -| Google Sheets | googlesheets | data.table | | Default | As comma-separated data | -| Minitab | minitab / mtp | foreign | | Default | | -| Pipe-separated data | psv | data.table | data.table | Default | | -| R syntax | r | base | base | Default | | -| SAS | sas / sas7bdat | haven | haven | Default | Export is deprecated | -| SAS XPORT | xport / xpt | haven | haven | Default | | -| SPSS | sav / spss | haven | haven | Default | | -| SPSS (compressed) | zsav | haven | haven | Default | | -| SPSS Portable | por | haven | | Default | | -| Saved R objects | rda / rdata | base | base | Default | | -| Serialized R objects | rds | base | base | Default | | -| Stata | dta / stata | haven | haven | Default | | -| Systat | syd / systat | foreign | | Default | | -| Tab-separated data | / tsv / txt | data.table | data.table | Default | | -| Text Representations of R Objects | dump | base | base | Default | | -| Weka Attribute-Relation File Format | arff / weka | foreign | foreign | Default | | -| XBASE database files | dbf | foreign | foreign | Default | | -| Apache Arrow (Parquet) | parquet | arrow | arrow | Suggest | | -| Clipboard | clipboard | clipr | clipr | Suggest | default is tsv | -| EViews | eviews / wf1 | hexView | | Suggest | | -| Fast Storage | fst | fst | fst | Suggest | | -| Feather R/Python interchange format | feather | arrow | arrow | Suggest | | -| Graphpad Prism | pzfx | pzfx | pzfx | Suggest | | -| HTML Tables | htm / html | xml2 | xml2 | Suggest | | -| JSON | json | jsonlite | jsonlite | Suggest | | -| Matlab | mat / matlab | rmatio | rmatio | Suggest | | -| OpenDocument Spreadsheet | ods | readODS | readODS | Suggest | | -| OpenDocument Spreadsheet (Flat) | fods | readODS | readODS | Suggest | | -| Serialized R objects (Quick) | qs | qs | qs | Suggest | | -| Shallow XML documents | xml | xml2 | xml2 | Suggest | | -| YAML | yaml / yml | yaml | yaml | Suggest | | +| Name | Extensions / “format” | Import Package | Export Package | Type | Note | +| :---------------------------------- | :---------------------------------- | :------------- | :------------- | :------ | :----------------------------- | +| Archive files (handled by tar) | tar / tar.gz / tgz / tar.bz2 / tbz2 | utils | utils | Default | | +| Bzip2 | bz2 / bzip2 | base | base | Default | | +| Gzip | gz / gzip | base | base | Default | | +| Zip files | zip | utils | utils | Default | | +| Ambiguous file format | dat | data.table | | Default | Attempt as delimited text data | +| CSVY (CSV + YAML metadata header) | csvy | data.table | data.table | Default | | +| Comma-separated data | csv | data.table | data.table | Default | | +| Comma-separated data (European) | csv2 | data.table | data.table | Default | | +| Data Interchange Format | dif | utils | | Default | | +| Epiinfo | epiinfo / rec | foreign | | Default | | +| Excel | excel / xlsx | readxl | writexl | Default | | +| Excel (Legacy) | xls | readxl | | Default | | +| Fixed-width format data | fwf | readr | utils | Default | | +| Fortran data | fortran | utils | | Default | No recognized extension | +| Google Sheets | googlesheets | data.table | | Default | As comma-separated data | +| Minitab | minitab / mtp | foreign | | Default | | +| Pipe-separated data | psv | data.table | data.table | Default | | +| R syntax | r | base | base | Default | | +| SAS | sas / sas7bdat | haven | haven | Default | Export is deprecated | +| SAS XPORT | xport / xpt | haven | haven | Default | | +| SPSS | sav / spss | haven | haven | Default | | +| SPSS (compressed) | zsav | haven | haven | Default | | +| SPSS Portable | por | haven | | Default | | +| Saved R objects | rda / rdata | base | base | Default | | +| Serialized R objects | rds | base | base | Default | | +| Stata | dta / stata | haven | haven | Default | | +| Systat | syd / systat | foreign | | Default | | +| Tab-separated data | / tsv / txt | data.table | data.table | Default | | +| Text Representations of R Objects | dump | base | base | Default | | +| Weka Attribute-Relation File Format | arff / weka | foreign | foreign | Default | | +| XBASE database files | dbf | foreign | foreign | Default | | +| Apache Arrow (Parquet) | parquet | arrow | arrow | Suggest | | +| Clipboard | clipboard | clipr | clipr | Suggest | default is tsv | +| EViews | eviews / wf1 | hexView | | Suggest | | +| Fast Storage | fst | fst | fst | Suggest | | +| Feather R/Python interchange format | feather | arrow | arrow | Suggest | | +| Graphpad Prism | pzfx | pzfx | pzfx | Suggest | | +| HTML Tables | htm / html | xml2 | xml2 | Suggest | | +| JSON | json | jsonlite | jsonlite | Suggest | | +| Matlab | mat / matlab | rmatio | rmatio | Suggest | | +| OpenDocument Spreadsheet | ods | readODS | readODS | Suggest | | +| OpenDocument Spreadsheet (Flat) | fods | readODS | readODS | Suggest | | +| Serialized R objects (Quick) | qs | qs | qs | Suggest | | +| Shallow XML documents | xml | xml2 | xml2 | Suggest | | +| YAML | yaml / yml | yaml | yaml | Suggest | | Additionally, any format that is not supported by **rio** but that has a known R implementation will produce an informative error message diff --git a/data-raw/single.json b/data-raw/single.json index 5da8dfd..0af42e4 100644 --- a/data-raw/single.json +++ b/data-raw/single.json @@ -781,6 +781,15 @@ "import_function": "data.table::fread", "export_function": "data.table::fwrite", "note": "" + }, + { + "input": "dat", + "format": "dat", + "type": "import", + "format_name": "Ambiguous file format", + "import_function": "data.table::fread", + "export_function": "", + "note": "Attempt as delimited text data" } ] diff --git a/tests/testthat/test_format_csv.R b/tests/testthat/test_format_csv.R index c872de6..81508e7 100644 --- a/tests/testthat/test_format_csv.R +++ b/tests/testthat/test_format_csv.R @@ -64,3 +64,13 @@ test_that("fread is deprecated", { lifecycle::expect_deprecated(import(iris_file, fread = FALSE)) }) }) + +test_that("dat (ambiguous file format) will be attempted #430", { + withr::with_tempfile("iris_file", fileext = ".dat", code = { + readr::write_delim(iris, file = iris_file) + expect_error(suppressMessages(import(iris_file)), NA) + expect_message(z <- import(iris_file)) + ## export is not supported though + expect_error(export(iris, iris_file)) + }) +})