Description Usage Arguments Value See Also Examples
Read multiple CSV files from a directory (folder)
1 2 3 4 5 6 7 8 9 10 11 12 13 | read_dir_csv(
path = ".",
...,
all = F,
recurse = F,
strict_csv_ext = T,
regexp = ".",
invert = F,
ignore.case = F,
perl = F,
fixed = F,
snake_case = F
)
|
path |
Character: Path to desired directory which contain file, default is "." working directory. (passed to |
... |
Argument to pass to |
all |
If |
recurse |
If |
strict_csv_ext |
If |
regexp |
Character: Specify a regular expression to read from file names (passed to |
invert |
Logical: If |
ignore.case |
If FALSE, the regular expression matching is case sensitive and if |
perl |
Logical: Should Perl-compatible regexps be used? (passed to |
fixed |
Logical: If |
snake_case |
If |
A list of tibbles
readr::read_csv()
https://readr.tidyverse.org
fs
package
https://fs.r-lib.org/index.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #' # Not run
if(FALSE){
# Read form current working directory by default
read_dir_csv()
# And file names are set to names of each data frame in a list
# Give a directory path
read_dir_csv("path/to/dir")
# Also, can read from every sub-directory of given directory
read_dir_csv("path/to/dir", recurse = T)
# Can specify regular expression of file names to read.
read_dir_csv(regexp = "[[:digit:]]+") # CSV file name contains numbers
# If set strict_csv_ext = F and remove regex which require file name ending with .csv
# it might read other file type as well (if you like)
read_dir_csv(regexp = "[[:digit:]]+\\.txt$", strict_csv_ext = FALSE) # Try read .txt file
# If you want file names in snake_case (require snakecase package)
read_dir_csv(snake_case = TRUE)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.