pattern when reading multiple files and the pattern option

Hello,

I am trying to read multiple .xls files and I am not sure how the pattern option actually works. For example my .xls files are saved as sba_california , sba_illinois , etc.

What is the appropriate pattern code for the files to read? I think this is where I am messing up. Here is my code:

sba <-  list.files(path="raw/sba/", pattern="sba_.xls", full.names = TRUE) 
df.list <- lapply(sba,read_excel) 
bind_rows(df.list)
df.list

Thank you.

The pattern argument takes "Regular Expressions" (RegEx) so maybe something like this
pattern="^sba_.+\\.xls$".
RegEx describes a text pattern so there are many ways in which you can describe them some more specific than others.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.