Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rajguntoju opened this issue Sep 23, 2024 · 1 comment

Comments

@rajguntoju
Copy link

rajguntoju commented Sep 23, 2024

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")        
@jorwoods
Copy link
Contributor

What is the error you're getting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants