Alteryx Designer Desktop Discussions

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

Open and Save an excel file before importing them in to a workflow

nzp1
7 - Meteor

I have a list of excel files that when just using the input tool I get that it is missing the xml schema. If I open the file manually and resave it clears the error but have to do this each time the files or exported from the product. There are no API endpoints tied to this area of the product.

 

I have used a python tool to do this function. I use the directory tool to get a list of files within the folder that I need to open.  On the python tool I install packages "xlwings" and "xlrd".

 

I then attempt to use the following Python code.

 

df = Alteryx.read("#1")
x = df['FullPath']
df['newvalue'] = df['FullPath']
import xlwings as xw
wb = xw.Book(fullname='C:\Calendar_Events_Business_PRIVILEGE_Tax.xlsx')
wb.api.RefreshAll()
wb.save(path='C:\Calendar_Events_Business_PRIVILEGE_Tax.xlsx')

 

It works fine if I hard code the filepath but fails when I replace the the hard coded path to pull data from the workflow.

wb = xw.Book(fullname=df['FullPath'])   I get the message below.  Like the variable is not passthrough.

 

 

nzp1_0-1659448794180.png

 

1 REPLY 1
Emmanuel_G
13 - Pulsar

Hi @nzp1 ,

 

Can you test by doing a for loop that will iterate over each item in the list of file paths and apply Book function on each of these ?

 

By looping, you perform this process for each path uniquely and append each results in list or empty dataframe.

 

I think the fullname argument of the Book method does not accept columns but a path value only ( such as in the screenshoot below ). But what you provide is a column of a pandas dataset.

 

xlwings documentation : https://docs.xlwings.org/en/0.25.0/connect_to_workbook.html

Emmanuel_G_0-1659451577047.png

 

Labels