I have an excel workbook that contains some sheets. Few of these sheets are very similar, but some are not. I am trying to learn better practice of using csv instead. I was trying to read these as csv as below:
path <- "Data/df.xlsx"
read_then_csv <- function(sheet, path) {
pathbase <- path %>%
basename() %>%
tools::file_path_sans_ext()
path %>%
read_excel(sheet = sheet) %>%
write_csv(paste0(pathbase, "-", sheet, ".csv"))
}
file <- path%>%
excel_sheets() %>%
set_names() %>%
map(read_then_csv, path = path)
All of these sheets are read properly. However, my concerns are:
-
They are automatically saved in the main directory. I would like for them to be not saved at all or if they have to be, then under Data folder as seen in the path.
-
I would also like to go to each sheet and wrangle it. But not sure how to manipulate each sheet separately.
Thanks for your help!