Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask 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

 

@binuacs @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)
binuacs
21 - Polaris

@BRRLL99 updated macro attached

image.png

BRRLL99
11 - Bolide
 

Hi @binuacs 

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

binuacs
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 @binuacs and @davidskaife solution fits what you need.

Labels
Top Solution Authors