Qlik Community

QlikView Documents

Documents for QlikView related information.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.

QlikView and Python Integration

sinanozdemir
Valued Contributor III

QlikView and Python Integration

Python is a very popular scripting language and below explains how to implement Python into QlikView by using the edit module.

In the below example, we will be returning operating system info by using Python’s platform module. First, we need to create our py (Python document):

python.PNG

Since this document is intended for audiences who are familiar with Python, I won’t be going through what the above Python code does, but in a nutshell we are creating a class and defining all necessary attributes and a function in order to use it via VBS. After that, we will need to save this document in a folder. I saved this as OperatingSystem.py on my desktop for the demonstration purpose and executed it on cmd:

cmd.PNG

As you can see, all the function that is defined within the class is registered, and available as a Windows library. Now the fun part, writing a macro in QlikView. Let’s bring the edit module window and type the below script which will display a message box with the operating system info:

editmodule.PNG

And then assign this macro to a button. Let’s test if the script is working:

qlik.PNG

If you have any questions, please don’t hesitate to contact me.

Happy scripting.

Required Python Modules:


win32com – This is an external module called Pywin32 that needs to be downloaded

Pythoncom – This module comes with Python

Comments
manojkulkarni
Valued Contributor II

Thanks for sharing the document. I was looking for some samples on the same.

Not applicable

Hi Sinan, Thanks for sharing.....Useful Information.

Emmanuelle-Bustos
Valued Contributor

Great for macros!

Not applicable

Hi Sinan,

I ran the OperatingSystem.py but everytime I click the button with the macro defined above, it redirects me to the module editor.

The issue appears to be with "response = PythonUtils.MachineInfo()" because when I write macro without it and print "ABC" in MsgBox, it works just fine.

P.S. I am new with Qlik and Python.

MVP
MVP

Hi, I wonder what use case does this solve? I rather call py scripts during a load process to get the data results into the Qlik data model..

pauljohansson
Contributor III

Hej,

Wouldnt a use case be to allow for manipulation of input parameters. 


Call Phyton with selected parameters - generate a new result in Phyton - get the new data set back QV.  In other words, let the user stay in QV, but still accessing Phyton calls.


br

Paul

MVP
MVP

With this approach you cannot get back a dataset you can use with your Qlik data. Btw. server-side extensions (available for Qlik Sense and coming soon fo QlikView, I guess) will solve this use case.

stefanobombo
Visitor

I have PyCharm for programming with python. Why in PyCharm the library pythoncom doesn't exsist ? how download it?

b_garside
Valued Contributor

This is all I would like to do.

Is to Execute a Python script then use the output data in the Qlik ETL script.

How can this be done?  I have not seen a post that simply explains this.

Qlik says there is integration, but I have not seen a simple post on it?

Instead having to go through all the hoops of configuring a SSE why don't they allow us to use a single command  like EXEC with switches that allows us to run a *.py script ?

julietotsch
New Contributor II

I have done this and received the following error message:

ActiveX component can't create object: 'PythonForVBS.Utilities'

I'm using Python 3.6 and QlikView 12.10.20500.0 SR7.  Could that be the issue?

Version history
Revision #:
1 of 1
Last update:
‎11-20-2015 10:29 PM
Updated by: