'site_name': '<YOUR_SITE_NAME>', 'site_url': '<YOUR_SITE_URL>' } } conn = TableauServerConnection(config, env='tableau_staging') #Logging into Tableau server conn.sign_in() # get a dataframe which has all the sites present, we can access contentUrl from this dataframe to loop over. sites = get_sites_dataframe(conn) print(f'Avaiable sites are {sites}') for i in sites['contentUrl']: conn.switch_site(i) # switching to the site for each site in a list print(f'Current site is {i}') # getting a dataframe of all users in that current site all_users_data = get_users_dataframe(conn) # converting last-login columns to a datetime column as currently it is Object type all_users_data['lastLogin'] = pd.to_datetime(all_users_data['lastLogin']) # creating a new column with just now() time, converting to same timezone as lastLogin Column else it will throw TypeError: DatetimeArray subtraction must have the same timezones or no timezones all_users_data['later_time'] = datetime.now(tz=timezone.utc) all_users_data['duration in days'] = (all_users_data['later_time'] - all_users_data['lastLogin']).dt.days # Filtering out all users email address and their names so that we can contact them , where days not logegd is greater than n days users_not_logged_in = all_users_data[
# signing in to the Tableau server conn.sign_in() # get all the sites on Server in a dataframe sites_data = get_sites_dataframe(conn) site_choose = input('Under which site do you want to publish the data source ') project_choose = input( 'Under which Project do you want to publish the data source ') x = str(sites_data[sites_data['name'] == site_choose]['contentUrl']) ##print(type(x)) #print(x.split()[1]) # Switching to the site which user entered, and where he want to publish data source conn.switch_site(x.split()[1]) res = conn.query_projects() # gettign the project site where we want to publish our data sources project_id = [ i['id'] for i in res.json()['projects']['project'] if i['name'] == project_choose ] project_id = str(project_id[0]) print(project_id) # changing to the directory where all our data sources are saved # looping over all data sources and publsihing them on server for i in glob.glob('/Users/surbhiagrawal/Downloads/sample/*.hyper'): print(i.split('/')[-1])