0

I was hoping someone could give me some pointers how to do this. I have multiple xlsx files in a directory that I'd like to convert to csv and then combine in one csv. I can do this with regular xlsx with the code below, but now I have to be able to read xlsx files that are password protected. Any ideas how I'd get around that?

library(rio)
library(plyr)

##LOAD, CONVERT AND COMBINE TO CSV
#convert all xlsx to csv
xls <- dir(pattern = "xlsx")
created <- mapply(convert, xls, gsub("xlsx", "csv", xls))
unlink(xls)

#combine csv files in directory
combined_ll <- ldply(list.files(), read.csv, header=TRUE)

They all have the same password, so in theory I should be able to read and unlock each file as it converts them. Any pointers would be so appreciated.

Petra
  • 43
  • 5
  • There seem to be multiple options for password protected files here: https://stackoverflow.com/questions/35852722/how-do-you-read-a-password-protected-excel-file-into-r/43915133. Have you tried any of those yet? – MrFlick Sep 24 '21 at 03:19
  • @MrFlick Yes, thanks I have. Unfortunately, none of those work with R's latest version. RDCOMClient, excel.link don't load. xlsx doesn't seem to have a password argument anymore and xlconnectjars is not available for the latest R version either. – Petra Sep 24 '21 at 03:27

0 Answers0