I retrieved a list of csv files with purrr::map and got a large list.
csv_files <- list.files(path = data_path, pattern = '\\.csv$', full.names = TRUE)
all_csv <- purrr::map(csv_files, readr::read_csv2)
names(all_csv) <- gsub(data_path, "", csv_files)
return all_csv
EDITED as suggested by @Spacedman
I further need to process each tibble/data frame separately within the process_csv_data function.
purrr::map(all_csv, process_csv_data)
How to retrieve the name of a single item in the large list without for loop?
names(all_csv)[42]
for example? – Spacedmanbasename(csv_files)
to get the file name part of the path.gsub
fails ifdata_path
is"."
, which it was when I tried this. – Spacedman