Hi,
I am getting the error:
ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.
my code:
from ayx import Alteryx
import pandas as pd
import zipfile
archive = zipfile.ZipFile(r'O:\Alteryx\Original - All fields - October 2022.zip')
xlfile = archive.open('Original - All fields - October 2022.xls')
df = pd.concat(pd.read_excel(xlfile, header = 1, sheet_name=None), ignore_index=True)
Alteryx.write(df, 1)
However I have this module installed on my python on pc and the code runs fine locally.
Why doesnt this work in alteryx python tool?
Thanks.
Solved! Go to Solution.
No it didnt - I think for some reason it is not being read in as a DF. Getting this at the bottom
KeyError: 0 and when i run your code:
ERROR: Alteryx.write(pandas_df, outgoing_connection_number): Currently only pandas dataframes can be used to pass data to outgoing connections in Alteryx
TypeError: Currently only pandas dataframes can be used to pass data to outgoing connections in Alteryx
pd.read_excel should always return a DataFrame pandas.read_excel — pandas 1.5.2 documentation (pydata.org). You can check if it is a dataframe by doing things like this: python - Testing if a pandas DataFrame exists - Stack Overflow. Does this work:
pd.read_excel(xlfile, header = 1, sheet_name=None).head()