4

I need to import some QVD files to work with them in python using pandas. Does anyone knows if its possible to import qvd files as a dataframe in a jupyter notebook for python2 ?

2 Answers2

1

This may help:

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')

Copied from: https://community.qlik.com/t5/New-to-QlikView/How-to-extract-QVD-data-using-python/td-p/1398020

  • I have an environment of Qlik sense only (no QlikView), I struggled to make it work, always stuck in Dispatch('QlikTech.QlikView'), how to get through of it? – kidgu Oct 09 '19 at 07:18
  • I tried this, the QV create document wizard starts up. – Standin.Wolf May 18 '20 at 16:33
0

No, you can't, see http://help.qlik.com/en-US/sense/September2017/Subsystems/Hub/Content/Scripting/work-with-QVD-files.htm

A QVD (QlikView Data) file is a file containing a table of data exported from Qlik Sense. QVD is a native Qlik format and can only be written to and read by Qlik Sense or QlikView.

oha
  • 79
  • 5
  • Incorrect, there are options. See @CapitaneNemo's reply above. Also I use the code in this repo and it meets my needs just fine: https://github.com/cosmocracy/qvdfile – Eric Kramer Mar 14 '23 at 14:15