Hi,
I have a process for which I need to use a password protected file. I have tried using the python tool to unlock the file but it keeps giving me package errors. the msoffcrypto and openpyxl packages aren't being installed. I don't have admin access so can't run as an administrator to install them either.
Code:
from ayx import Alteryx
import pandas as pd
import io
import msoffcrypto
import os
import openpyxl
df = Alteryx.read('#1')
protected_excel_filepath = df.iloc[0,0]
if os.path.exists(protected_excel_filepath):
unprotected_excel_content = io.BytesIO()
with open(protected_excel_filepath, 'rb') as f:
msoffcryptoobj = msoffcrypto.OfficeFile(f)
msoffcryptoobj.load_key(password="abc123")
unprotected_excel_content = io.BytesIO()
msoffcryptoobj.decrypt(unprotected_excel_content)
df= pd.read_excel(unprotected_excel_content,engine = "openpyxl")
Alteryx.write(df,2)
You have to run Alteryx as admin (not install the admin version)- if not - you'll have to install the packages via CLI in your Python venv.
also - you'll need to have the install.packages command for your non-standard packages.