Tableau Server Extract all workbooks attributes

Convert Tableau Server Client Workbooks List to Pandas DataFrame


When you use the Tableau Server Client (TSC) to get all workbooks from the server:

all_workbooks = list(TSC.Pager(server.workbooks))

You get a list of workbook objects. Each object has attributes like id, name, project_name, owner_id, etc.

Convert all_workbooks List to Pandas DataFrame:

import pandas as pd

import tableauserverclient as TSC


# Assuming you already have `all_workbooks` as a list

all_workbooks = list(TSC.Pager(server.workbooks))


# Extracting relevant attributes into a list of dictionaries

workbooks_data = [

  {

    'id': wb.id,

    'name': wb.name,

    'project_name': wb.project_name,

    'owner_id': wb.owner_id,

    'created_at': wb.created_at,

    'updated_at': wb.updated_at,

    'size': wb.size,

    'show_tabs': wb.show_tabs,

    'webpage_url': wb.webpage_url,

  }

  for wb in all_workbooks

]


# Convert to DataFrame

df = pd.DataFrame(workbooks_data)


print(df)

Explanation:

• List comprehension: Extracts key attributes from each WorkbookItem object.

• Attributes commonly used:

• wb.id

• wb.name

• wb.project_name

• wb.owner_id

• wb.created_at

• wb.updated_at

• wb.size

• wb.show_tabs

• wb.webpage_url


You can customize this list based on the attributes you need from the WorkbookItem object.

Sample Output:

         id      name   project_name    owner_id      created_at ... size show_tabs           webpage_url

0 abcd1234efgh5678   Sales Report Finance Project user123456789 2023-10-01 08:00:00 ... 2500   True https://tableau.server/view/...

1 wxyz9876lmno5432 Marketing Data Marketing Group user987654321 2023-11-05 10:30:00 ... 3100   False https://tableau.server/view/...

Key Notes:

• Make sure you import pandas and tableauserverclient.

• This approach is efficient and works well with TSC.Pager() results.

• You can easily export the DataFrame to CSV or Excel:

df.to_csv('tableau_workbooks.csv', index=False)



Would you like help with pagination handling, filtering specific workbooks, or exporting the DataFrame?


From Blogger iPhone client