Convert Excel file to CSV
This uses the workflow in here: https://readxl.tidyverse.org/articles/articles/readxl-workflows.html
This is preferred to converting Excel files by hand to avoid human error.
If files are in the visitor folder you might need to be complete the following while logged into visitor
Load the necessary packages
Get a list of files that we want to convert
Create a function that iterates through the excel files and saves it as a csv in the same folder the excel file was in
read_then_csv <- function(sheet, path) {
#remove the file extension
pathbase <- path %>%
tools::file_path_sans_ext()
#change file extension to csv and save with the sheet name
for(i in 1:length(sheet)){
path %>%
read_excel(sheet = i) %>%
write_csv(paste0(pathbase, "_", sheet[i], ".csv"))
}
}
Get the sheet name(s)
Iterate over all the xlsx files for each of the sheets
Check the files afterwards to make sure everything was converted properly
Check to see if there are any empty tables and get a list of files that were empty
Remove those empty table files
Remove xlsx files if everything looks in order