【问题标题】:Import QVD file into Jupyter notebook - python2将 QVD 文件导入 Jupyter 笔记本 - python2
【发布时间】:2018-03-13 01:27:33
【问题描述】:

我需要导入一些 QVD 文件以使用 pandas 在 python 中使用它们。有谁知道是否可以在 python2 的 jupyter notebook 中将 qvd 文件作为数据框导入?

【问题讨论】:

  • 我需要同样的

标签: dataframe import jupyter-notebook python-import qliksense


【解决方案1】:

不,你不能,见http://help.qlik.com/en-US/sense/September2017/Subsystems/Hub/Content/Scripting/work-with-QVD-files.htm

QVD(QlikView 数据)文件是包含从 Qlik Sense 导出的数据表的文件。 QVD 是一种原生 Qlik 格式,只能由 Qlik Sense 或 QlikView 读写

【讨论】:

    【解决方案2】:

    这可能会有所帮助:

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

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

    【讨论】:

    • 我只有 Qlik sense 的环境(没有 QlikView),我努力让它工作,总是卡在 Dispatch('QlikTech.QlikView') 中,如何度过它?
    • 我试过了,QV创建文档向导启动了。
    【解决方案3】:

    看来今年(2021)开发了一个python包https://pypi.org/project/qvd/也许能帮上忙。我会在我身边测试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-28
      • 2020-11-20
      • 2017-12-04
      • 2020-11-22
      • 1970-01-01
      • 2023-03-26
      • 1970-01-01
      相关资源
      最近更新 更多