0

I need to read a dataset into R from a file that has to be password protected. It's currently an SPSS file, but I'm allowed to convert it into a password protected excel file. I tried using excel.link's xl.read.file, but it prompts me to open excel and enter the password and then it just hangs forever. I'm not married to data being in excel. I'd just like a straight forward way to read in some kind of password protected file into R.

Here's the code I was trying:

library(excel.link)

x <- xl.read.file("Y:/Path/data.xlsx",
                  password = "123",
                  write.res.password = "123")

I also tried to use this solution: https://stat.ethz.ch/pipermail/r-help/2011-March/273660.html

But I need the packages to be from CRAN.

James B
  • 474
  • 2
  • 10
  • 1
    Your code works for me with no Excel prompt and no hanging. What happens when, in an experiment, you get rid of the password protection and just try to open the file? – John Coleman May 22 '20 at 19:36
  • With no password it works fine. I'm in a somewhat restricted environment, so I'm guessing that's breaking whatever xl.read.file is trying to do. That's also why I need a package off CRAN and can't just download something off of github. – James B May 22 '20 at 19:38
  • 1
    A `Y` drive sounds like it might be over a network. Don't know if that is relevant. Perhaps you could encrypt the data in the file but leave the file itself unprotected, then decrypt the data in R after you read it. – John Coleman May 22 '20 at 19:42
  • 1
    You may want to try using the "xlsx" package. That has the ability to to read password protected Excel, files. Of course you will have to protect your R script to prevent the password from leaking out. – Dave2e May 22 '20 at 19:50
  • Yeah ironically I'm on a restricted share drive, so I don't even know why this password is needed, but I'm not allowed to take it off. Encryption is a good idea though if I'm allowed to try it. I also just tried xlsx, but it hanged so something on my end must be preventing it from working. Maybe all the google indexed threads are old, but I'm surprised the xlsx package wasn't ever mentioned search results for opening password protected excel files. – James B May 22 '20 at 19:59

0 Answers0