Skip to content

Tableau server update display name and email id by reading the info from csv file #1473

Closed
@rajguntoju

Description

@rajguntoju

Requirement:
We have around 2200 user id and their corresponding display name and email id in the csv file. Now I have to build a script which will read that csv file and update display name and email id in tableau server.
CSV file has userid, full name, email columns

Approach:
Initially I wrote simple script which will read the csv file and retrieve the user details from tableau server by applying userid as filter.
Then assign email, full name value to that user item and update the user in tableau server.
However, it's updating only to first 8 user id and then it's messing up. So I thought I can apply this update function in batches, so started reading the csv file in batch and applying update function but still its failing.

Does anyone have faced this issue before when updating such huge number of user id's if yes what's the solution followed?
Any help would be greatly appreciated

import sys
import tableauserverclient as TSC
import pandas as pd
#Tableau Connection
tableau_auth = TSC.TableauAuth("USERNAME","PWD","site")
server = TSC.Server('server',use_server_version=True)
#Read the data from users list csv file
filename='filepath\\testusers.csv'
#Define filter that can be applied while retrieving data from server
req_option = TSC.RequestOptions()
##rows=pd.Index(df)
batchsize=5

for df in pd.read_csv(filename,chunksize=batchsize,skip_blank_lines=True,iterator=True):
    for index,row in df.iterrows():
        with server.auth.sign_in(tableau_auth):

            req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,TSC.RequestOptions.Operator.Equals,row.iloc[0]))
            all_users,pagination_item = server.users.get(req_options=req_option)
            user1 = TSC.UserItem()
            name=row.iloc[0]
            user1_id=[user.id for user in all_users]
            user1.id=''.join(user1_id)
            user1.fullname=row.iloc[1]
            user1.email=row.iloc[2]
            user1=server.users.update(user1)
            print("user updated")
    server.auth.sign_out()
    print("signed out")        

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions