Description Usage Arguments Details Examples
Composable utility functions for reading multiple files from a given location.
1 2 3 4 5 6 7 | read_all()
using(.p, readfun = read_csv, ...)
into_env(.p, namefun = default_naming)
into_tibble(.p, namefun = default_naming, namecol = "origin")
|
readfun |
the function which will be used to read each individual file. Defaults to read_csv. |
... |
parameters passed on to readfun (e.g. ‘delim = ’;'') |
namefun |
a function which takes a string and returns a string. Each file processed by 'into_env' will call this function once to determine which key to use into the destination environment. The default function uses the file name without its extension and replaces '-' with '_'. |
path |
filesystem path from where to read files (e.g. '/home/user/files'). |
pattern |
a pattern to filter files by. Accepts wildcards (e.g. ‘pattern = ’*.csv''). Defaults to '*' (read all files). |
bucket |
name of the GCS bucket where to read files from. |
prefix |
GCS prefix of the files to be read. |
reads a set of files from the local filesystem.
reads a set of files from a Google Cloud Storage bucket.
specifies which read function to apply to the downloaded data. Defaults to read_csv
combines all files into a single Tibble. Equivalent to looping through the files, reading them, and then binding them together.
reads each file and assigns its contents to a key within an environment.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # So we can use %>% syntax.
library(magrittr)
# Folder with two files
path <- system.file('extdata', 'read_all', package = 'megautils')
# Reads contents as single tibble.
schema <- list(a = readr::col_integer(), b = readr::col_integer())
read_all() %>%
using(readr::read_csv, col_types = schema) %>%
from_fs(path) %>%
into_tibble()
# Reads contents into environment.
e <- read_all() %>%
using(readr::read_csv, col_types = schema) %>%
from_fs(path) %>%
into_env()
ls(e)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.