Importing files from several folders with fs

Hi! I would like to know how can I load several excel files that are inside other several folders. - Almost 50 folders with 3 excels each - . I read about fs, however how can I used in my case? Please, any comment will be highly appreciate. Thanks a lot. Regards

Is there a reason you cannot use the list.files() function? It has a pattern argument that you can use to find files whose name ends with xlsx and it has a recursive argument that allows you to look in sub folders. If your 50 folders are all sub directories of the folder Data, you could get all of the file names with

FileNames <- list.files(path = "Data", pattern = "xlsx$", recursive = TRUE, full.names = TRUE)

You can then make a list of the same length as FileNames and read each Excel file in as an element of that list. Would something like that work for you?

Thanks a lot for your response. That's helped me a lot.
As I mentioned, I just read about fs. Looks great, I think, but I require to put more effort in it.
Regards

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