使用python

时间:2018-12-08 18:29:29

标签: python pandas tableau

我正在寻找一种使用python下载Tableau视图的方法。我可以通过python在线登录tableau,并可以查看列出的工作簿和视图。

由于用户没有工作簿的权限,因此无法下载工作簿,但是查看我只能输入chrome,但无法找到使用python的方法。我也想将视图保存在pandas数据框中。

如果仍然可以进行上述操作,请告诉我?

# coding=utf-8

import tableauserverclient as TSC
import argparse
import requests
import pandas as pd
import csv


parser = argparse.ArgumentParser()
args = parser.parse_args()

tableau_auth = TSC.TableauAuth('admin', 'admin', site_id='test')
server = TSC.Server('https://10az.online.tableau.com')
server.auth.sign_in(tableau_auth)
# print(server.projects.get())
with server.auth.sign_in(tableau_auth):
    all_workbooks, pagination_item = server.workbooks.get()
    print("\nThere are {} workbooks on site: ".format(pagination_item.total_available))
    print([workbook.name for workbook in all_workbooks])

    if all_workbooks:
        sample_workbook = all_workbooks[3]
        server.workbooks.populate_views(sample_workbook)
        print("\nName of views in {}: ".format(sample_workbook.name))
        print([view.name for view in sample_workbook.views])
        print([view.id for view in sample_workbook.views])

        server.workbooks.populate_connections(sample_workbook)
        print("\nConnections for {}: ".format(sample_workbook.name))
        print(["{0}({1})".format(connection.id, connection.datasource_name)
               for connection in sample_workbook.connections])

        view_id = 'ddd'
        server_url = 'https://10az.online.tableau.com'
        src_url = "https://10az.online.tableau.com/#/site/abc/views/test/AccountAdvertisersList.csv" \
                  .format(server_url, server.version, server.site_id, view_id)

        # path = server.workbooks.download(sample_workbook.id)

0 个答案:

没有答案