In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests after December 31, 2025. Set up your security questions now so you can recover your account anytime, just log out and back in to get started. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Read Password protected xlsb files using Python

BRRLL99
11 - Bolide

Hi

I have multiple xlsb files in a folder which are protected by password. I would like to read only that sheet name is "Main"

Existing python code is reading only first sheet from each file 

 

Attaching python code workflow for reference and sample xlsb file

For sample attached attaching xlsx file

 

@binu_acs @Qiu @davidskaife 

5 REPLIES 5
davidskaife
14 - Magnetar

Hi @BRRLL99 

 

You could try changing the Python to this:

 

df_master = pd.DataFrame()

input_data = Alteryx.read("#1")

for i in range(len(input_data['FullPath'])):
    full_name = input_data['FullPath'][i]
    print(full_name)

    pwd = input_data['excel_password'][i]

    xl_app = w3c.gencache.EnsureDispatch('Excel.Application')
    xl_wb = xl_app.Workbooks.Open(full_name, False, True, None, pwd)

    sheet = xl_wb.Worksheets('Main')  # Access only the 'Main' tab
    content = sheet.UsedRange.Value

    df = pd.DataFrame(list(content))

    new_header = df.iloc[0]
    df = df[1:]
    df.columns = new_header

    df_master = df_master.append(df, ignore_index=True)

    xl_wb.Close(SaveChanges=0)
    del xl_wb
    xl_app.Quit()

Alteryx.write(df_master, 1)
binu_acs
21 - Polaris

@BRRLL99 updated macro attached

image.png

BRRLL99
11 - Bolide
 

Hi @binu_acs 

I'm facing follow error, is there any reason for this ??

binu_acs
21 - Polaris

@BRRLL99 Can you post the full error message 

Qiu
21 - Polaris
21 - Polaris

@BRRLL99 
Thank you for mentioning me but I dont really knwo about Python.
Hope @binu_acs and @davidskaife solution fits what you need.

Labels
Top Solution Authors