python - 在 TSC 中应用过滤器后将 tableau View 导出为 pdf

标签 python tableau-api

我正在尝试使用 python tableau 服务器客户端导出 tableau View 。
以下是用于创建 pdf 的代码部分。

server.views.populate_pdf(view, options)

with file("dashboard.pdf", 'wb') as f:
    f.write(view.pdf)

此代码工作正常,并且正在将 View 导出到 pdf 文件。
我的 Tableau 仪表板几乎没有过滤器(例如产品类型、供应商)。
如何在导出时添加 View 过滤器,以便仅获取特定产品类型和供应商的数据?

最佳答案

我想我使用以下示例找到了答案。
https://github.com/tableau/server-client-python/blob/master/samples/export.py
我们需要添加 View 过滤器(vf),如下所示:

option_factory = getattr(TSC, "PDFRequestOptions")
options = option_factory().vf("product_type","Handphone")
options.vf("vendor","vendor1")

#In case of multi select filter we can use coma separated values as followed
options.vf("vendor","vendor1,vendor2")
#To get the list of all filter options use
print options.view_filters

引用: https://github.com/tableau/server-client-python/blob/master/tableauserverclient/server/request_options.py#L90

一旦我们准备好过滤器选项,我们就可以将其传递到填充 pdf。

server.views.populate_pdf(view, options)
with file("dashboard.pdf", 'wb') as f:
    f.write(view.pdf)

关于python - 在 TSC 中应用过滤器后将 tableau View 导出为 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53839824/

相关文章:

mysql - Tableau关系数据模型

python tensorflow - relu 未在自动编码器任务中学习

postgresql - 使用 HLL 在 Tableau 上执行提取以获取非重复计数

datatables - 如何将我的 BI 工具连接到 YouTube API (ODBC)?

tableau-api - 使用身份验证嵌入 Tableau

tableau-api - 使用 Tableau 创建热图

python - TK 图像未出现

python - 子流程内的子流程。如何传播错误输出?

python - 如何在Python中替换方程中的变量

python - 无法引用类内的输入字段?