Skip to content

Commit 34a2d01

Browse files
authored
Merge pull request #281 from frictionlessdata/readr
Pass multiple file paths directly to readr
2 parents b7fce08 + 266c159 commit 34a2d01

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

NEWS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* `write_package()` no longer writes to `"."` by default, since this is not allowed by CRAN policies. The user needs to explicitly define a directory (#205).
1616
* `null` values in a read `datapackage.json` are now retained by `write_package()`, rather than being changed to empty lists. Properties assigned by the user to `NA` and `NULL` remain being written as `null` and removed respectively (#203).
1717
* New vignettes `vignette("data-package")`, `vignette("data-resource")`, `vignette("table-dialect")` and `vignette("table-schema")` describe how frictionless implements the Data Package standard. The (verbose) function documentation of `read_resource()` and `create_schema()` has been moved to these vignettes, improving readability and maintenance (#208, #246).
18-
* The included dataset `example_package` is removed in favour of the function `example_package()`. This function allows to reproducibly provide a local Data Package, without the need for an internet connection. The `observations` resource was also changed from a remote to a local resource and from CSV to TSV. **This change affects the use of `example_package` in older versions of frictionless.** We recommend to update frictionless to the latest version (#114, #253).
18+
* The included dataset `example_package` is removed in favour of `example_package()`. This function allows to reproducibly provide a local Data Package, without the need for an internet connection. The `observations` resource was also changed from a remote to a local resource and from CSV to TSV. **This change affects the use of `example_package` in older versions of frictionless.** We recommend to update frictionless to the latest version (#114, #253).
1919

2020
## Changes for developers
2121

@@ -30,7 +30,7 @@
3030

3131
## Changes for users
3232

33-
* New function `print()` prints a human-readable summary of the Data Package, rather than a (long) list (#155).
33+
* New `print()` prints a human-readable summary of the Data Package, rather than a (long) list (#155).
3434
* `read_package()` no longer returns a message regarding rights and credit (#121). If `package$id` is a URL (e.g. a DOI) it will be mentioned in `print()`.
3535
* `add_resource()` accepts additional arguments via `...`. These are added as (custom) properties to the resource and are retained in `write_package()` (#195).
3636
* `read_resource()` now supports column selection via the `col_select` argument from `readr::read_delim()`. This can vastly improve reading speed (#123). [Tidy selection](https://dplyr.tidyverse.org/reference/dplyr_tidy_select.html) is not supported.
@@ -81,7 +81,7 @@
8181
* `add_resource()` now supports adding `schema` via path or URL.
8282
* `write_package()` now supports added data to be gzip compressed before being written to disk (#98).
8383
* `read_resource()` will now warn rather than error on unknown encoding (#86).
84-
* `package` objects no longer have or require the custom attribute `resource_names`, use new function `resources()` instead (#97).
84+
* `package` objects no longer have or require the custom attribute `resource_names`, use the new `resources()` instead (#97).
8585
* `package` objects no longer have or require the custom attribute `datapackage`, making it easier to edit them as lists (with e.g. `append()`).
8686

8787
# frictionless 0.10.0

R/read_from_path.R

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,25 @@ read_from_path <- function(package, resource_name, col_select) {
4747
}
4848
skip <- if (dialect$header %||% TRUE) 1 else 0
4949

50-
# Read data with read_delim for each path (returns tibble)
51-
purrr::map_df(
52-
paths,
53-
function(path) {
54-
readr::read_delim(
55-
file = path,
56-
delim = dialect$delimiter %||% ",",
57-
quote = dialect$quoteChar %||% "\"",
58-
escape_backslash = escape_backslash,
59-
escape_double = escape_double,
60-
col_names = field_names,
61-
col_types = col_types,
62-
# Use rlang {{}} to avoid "col_select" to be interpreted as the name of
63-
# a column, see https://rlang.r-lib.org/reference/topic-data-mask.html
64-
# col_select needs to be assigned/used above to avoid lazy eval error
65-
col_select = {{ col_select }},
66-
locale = locale,
67-
na = schema$missingValues %||% "",
68-
comment = dialect$commentChar %||% "",
69-
trim_ws = dialect$skipInitialSpace %||% FALSE,
70-
# Skip header row when present
71-
skip = skip,
72-
skip_empty_rows = TRUE
73-
)
74-
}
50+
# Read data (one or more paths) with read_delim (returns tibble)
51+
readr::read_delim(
52+
file = paths,
53+
delim = dialect$delimiter %||% ",",
54+
quote = dialect$quoteChar %||% "\"",
55+
escape_backslash = escape_backslash,
56+
escape_double = escape_double,
57+
col_names = field_names,
58+
col_types = col_types,
59+
# Use rlang {{}} to avoid "col_select" to be interpreted as the name of
60+
# a column, see https://rlang.r-lib.org/reference/topic-data-mask.html
61+
# col_select needs to be assigned/used above to avoid lazy eval error
62+
col_select = {{ col_select }},
63+
locale = locale,
64+
na = schema$missingValues %||% "",
65+
comment = dialect$commentChar %||% "",
66+
trim_ws = dialect$skipInitialSpace %||% FALSE,
67+
# Skip header row when present
68+
skip = skip,
69+
skip_empty_rows = TRUE
7570
)
7671
}

0 commit comments

Comments
 (0)