-1

problem:- python package pandas, openpyxl cant read excel with password protected.

action:- review decrypt excel files but still not working

result:- only pop-out password input box

Damon Lim
  • 1
  • 1
  • 10
  • Does this answer your question? [From password-protected Excel file to pandas DataFrame](https://stackoverflow.com/questions/15285068/from-password-protected-excel-file-to-pandas-dataframe) – AMC Mar 06 '20 at 02:25
  • https://stackoverflow.com/a/60556707/11674978 answer here simple and convenient – Damon Lim Mar 06 '20 at 02:30
  • The solution here is just to enter the password and make a non-protected copy of the file, right? Never mind the potential security issues, why not just open the file and save a copy manually? I’m not sure I agree that this is a solution to the problem described in the title and post, since you’re not actually reading the password protected file. – AMC Mar 06 '20 at 02:35
  • in the solution provided, we still need to know which is last column last row in order to read it as dataframe – Damon Lim Mar 06 '20 at 02:43
  • also according https://stackoverflow.com/a/53015707/11674978 if find last row slowly, but if you have data of 100k lines, very time consuming. in some situation i'm agree it's pretty good way to read it – Damon Lim Mar 06 '20 at 02:54
  • The answer you shared actually contains a link to yet another question on the subject, there seem to be a ton. I will try to go hunting for duplicates at some point. – AMC Mar 06 '20 at 02:56

1 Answers1

0

Using:- Anaconda, jupyter notebook

What to do? read the encrypted excel and export as non-encrypting excel and proceed.

import win32com.client
excel = win32com.client.Dispatch('Excel.Application')
workbook = excel.Workbooks.Open(r'C:\ltexSales.xlsx',False, True, None, 'password')
xlCSVWindows = 0x17
workbook.SaveAs(r'C:\ltexSales_decrypted.csv', FileFormat = xlCSVWindows, 
                Password = None)
workbook.Close()

import pandas as pd
df = pd.read_csv(r'C:\ltexSales_decrypted.csv')

So now you may use pandas to read it.

extra: be aware of all capital letter

Community
  • 1
  • 1
Damon Lim
  • 1
  • 1
  • 10