Reputation: 674
How do I read excel files just based on the first part of the file name? For example my file is "File_01_01_2019", where "File" is always the same but the date changes often, so I would want to read excel files that start with "File" in this scenario.
Upvotes: 0
Views: 717
Reputation: 6954
This should help you
library(readxl)
sapply(list.files(path = "your_path",
# regex that defines to start with "File" and ends with ".xlsx"
pattern = "^File.*\\.xlsx$",
full.names = TRUE),
read_excel)
Upvotes: 2