0

I found an example here How to open a password protected excel file using python? but I don't want to open the password protected Excel (.xlsx), but just want to read from one of the tabs without opening. How do I do that?

martineau
  • 119,623
  • 25
  • 170
  • 301
user13412850
  • 509
  • 1
  • 5
  • 16
  • 2
    What about the answers in the linked post? You seem to confuse opening the file in a window with opening the file in a file operation logic sense which just means that you read the file (partially) into memory and therefore "open" it in memory. – luk2302 Mar 05 '22 at 23:50
  • 2
    "Opening" a file **means** "telling the operating system to set up so that the program can start reading from the file". You cannot read anything from any kind of file without opening it, just like you can't drink from a juice box without opening it. – Karl Knechtel Mar 05 '22 at 23:57
  • ok, sorry am not a tech guy so to simplify what I was trying to do. Just like "pd.read_excel" helps me read from an excel although the file is not opened in windows, I wanted to read the content of a password protected file. But looks like I can't use "pd.read_excel" when there is password involved. – user13412850 Mar 06 '22 at 00:02
  • read your password-protected file the same way as the example you mentioned, then load it into pandas as a list or dictionary – eshirvana Mar 06 '22 at 00:12
  • sorry still a struggle, I managed to get to xlwb = xlApp.Workbooks.Open(filename, False, True, None, password). If I have to pull from a tab called "Markets" and from the range "A10 : D40" to a df, how do I do that? – user13412850 Mar 06 '22 at 00:26
  • 1
    prefect @eshirvana that solves my problem! very much appreciate your help again! – user13412850 Mar 06 '22 at 00:47

0 Answers0