Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to extract QVD data using python

Is there any way to extract data from QVD file using python script.

**sorry i never worked on qlikview but we have a requirement to extract data from qlikview pertaining to some tool we are building.

Thanks a million in advance.

14 Replies
avinashelite

QVD are native qlik readable file .....it has 3 parts

  • XML header to describe the fields in the table, the layout of the subsequent information and other meta-data.
  • Symbol tables in a byte stuffed format.
  • Actual table data in a bit-stuffed format.

As per I know you could extract the meta-data information not sure about the actual data

marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi Prabhat,

given that QVD is a proprietary format, you're likely to run into difficulties. You might look instead into saving your data into QVX files, then reading those.

QlikView QVX File Format

https://community.qlik.com/message/92107#92107

Marcus

VasilyEvdokienko
Contributor II
Contributor II

Try this:

def qvd_to_pandas(src_qvd):

    from tempfile import TemporaryDirectory
    from pathlib import Path

    from win32com.client import Dispatch
    import pandas as pd

    with TemporaryDirectory(dir='.') as tmp_dir:
        tmp_csv = Path(tmp_dir).absolute() / 'tmp.csv'
        tmp_qvw = Path(tmp_dir).absolute() / 'tmp.qvw'

        script = f'''    
        ExportTable: REPLACE LOAD * FROM {Path(src_qvd).absolute()} (qvd);
        STORE ExportTable INTO {tmp_csv} (txt);
        DROP TABLE ExportTable;
        '''

        qv = Dispatch('QlikTech.QlikView')
        active_doc = qv.CreateDoc()

        doc_properties = active_doc.GetProperties()
        doc_properties.script = doc_properties.script + script

        active_doc.SetProperties(doc_properties)
        active_doc.SaveAs(tmp_qvw)
        active_doc.ReloadEx(0, 1)

        active_doc.CloseDoc()
        qv.Quit()

        df = pd.read_csv(open(tmp_csv, encoding='utf8'), dtype=str)

    return df

df = qvd_to_pandas('my_qvd_file.qvd')
IAMDV
Luminary Alumni
Luminary Alumni

VasilyEvdokienko
Contributor II
Contributor II

Added attributes to my stackoverflow post. Thanks 😉
IAMDV
Luminary Alumni
Luminary Alumni

Lol! Nice situation to be in. I had a feeling that you are the same person. You see - I didn’t go too hard without knowing it. 😉

Does this only work on Windows OS? I tried on Mac OS and it doesn’t work.
VasilyEvdokienko
Contributor II
Contributor II

Integrity matters 🙂
Yes, only works on Windows. For Mac the solution may be in https://github.com/mattneub/appscript
thi_pham
Creator III
Creator III

I have an environment with Qlik sense only (no qlik view), how to make it work cause I always got error on the line: 

Dispatch('QlikTech.QlikView')

 

ajbilimoria
Partner - Contributor
Partner - Contributor

Hi, 

Thank you for this code, i tried to implement it and its working fine also but every time when its making communication, it opens Qlikview Desktop version for few seconds and close the same automatically.

Can we block that pop up?