List files in storage (similar to list.files())
Description
Section titled “Description”Lists blob files available via a storage handler created by [init_storage_handler()(init_storage_handler/) and returns their names, optionally filtered by directory (path) and a filename pattern.
list_blob_files(handler, path = NULL, pattern = NULL, full.names = TRUE)Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
handler |
A Python object of class StorageHandler. |
path |
Optional character string. Restrict results to blobs directly under this directory. |
pattern |
Optional regular expression. Only file names matching this pattern are returned. Matching is applied to the basename, not the full path. |
full.names |
Logical; if TRUE (default), return full blob paths. If FALSE, return only file names. |
A character vector of blob names (paths or file names).
Details
Section titled “Details”This function mimics the behaviour of base::list.files():
pathfilters blobs by their parent directorypatternis applied to the file name (not the full path)full.namescontrols whether full blob paths or only file names are returned
Internally, this function uses handler$list_blobs() and extracts the name field from each blob.
Examples
Section titled “Examples”handler <- init_storage_handler(env = "local")
# all fileslist_blob_files(handler)
# files in a directorylist_blob_files(handler, path = "SAMPLE")
# filter by patternlist_blob_files( handler, path = "SAMPLE", pattern = "^SAMPLE_(MONTHLY|YEARLY).*\\.csv$")
# only file nameslist_blob_files(handler, path = "SAMPLE", full.names = FALSE)