We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Alteryx usage with help of Python tool for validation of the excel

GT
6 - Meteoroid

I am trying to replicate a similar result to the Python output, in which two Excel files are used to generate the desired output by highlighting missing data in the input Excel file. The first Excel file is to be matched using regular expressions against the second Excel file (in which two sheets will be used for comparison with the first Excel sheet). Please suggest how I should proceed. I have attached python code for the reference as (kindly change extension from .txt to .py) .

GT_0-1757297550188.png

 

 

6 REPLIES 6
KGT
13 - Pulsar

You are getting an error on the packages. Have you installed os and openpyxl? I'm not sure if re is installed by default either, but I can't see an error for that one. The script is trying to import them, but if they are not installed, then there is nothing to call.

GT
6 - Meteoroid

I have installed it but in Alteryx its giving error, I have installed manually also openpyxl in its source path location.

KGT
13 - Pulsar

Have you installed it on the Alteryx Python install, or another Python version on your machine? 

 

In a new python tool on a canvas, check the list of packages installed, and if it is not there, then install.Packages([.....

 

The error being thrown above is because the modules can't be found. This is most commonly because the Packages aren't installed.

GT
6 - Meteoroid

How can i install openpyxl in Alteryx , I have installed it before installing Alteryx in Python. 

 

"Error: Python (6): ---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 4
2 import pandas as pd
3 import os
----> 4 from openpyxl import load_workbook
6 # Load incoming data from Alteryx
7 df = Alteryx.read("#1") # Assuming stream #1 contains joined & validated data
ModuleNotFoundError: No module named 'openpyxl' "

 

KGT
13 - Pulsar

If you installed it before installing Alteryx, then it will not be on the Alteryx Python install.

 

You generally need elevated permissions to install new packages, which is good, because it means that you can't just run a script installing 5 random packages with unintended consequences. If you can't do it in the Python tool (Alteryx running as admin if possible) with Package.installPackages(['openpyxl']) then you will need to use pip.

GT
6 - Meteoroid

Thank for the input, I reinstalled Python in admin mode and it resolved the issue.

Labels
Top Solution Authors