How to upload data to Tableau Server in Python

0 votes
I need to execute a python script that will upload/update a data file on a tableau server, so that the dashboard related to the datafile will be automatically updated every time I run the python script. I'm not sure how to go about doing that; the file I need to submit to the tableau server is in csv format, but I believe the server only accepts tableau files? In addition, I'm not sure which API to use for this.
Mar 4, 2022 in Tableau by Vaani
• 7,070 points
2,193 views

1 answer to this question.

0 votes

Then install the tableau-api-lib utility for Python (https://github.com/divinorum-webb/tableau-api-lib ), which may be found at https://github.com/divinorum-webb/tableau-api-lib. Then, to connect to your Tableau Server, follow these steps:

from tableau_api_lib import TableauServerConnection
from tableau_api_lib.utils.querying import get_projects_dataframe

tableau_server_config = {
        'my_env': {
                'server': 'https://YourTableauServer.com',
                'api_version': '<YOUR_API_VERSION>',
                'username': '<YOUR_USERNAME>',
                'password': '<YOUR_PASSWORD>',
                'site_name': '<YOUR_SITE_NAME>',
                'site_url': '<YOUR_SITE_CONTENT_URL>'
        }
}

conn = TableauServerConnection(tableau_server_config, env='my_env')
conn.sign_in()

Place to publish:

projects_df = get_projects_dataframe(conn)
print(projects_df[['full_name', 'ID']]

Publish:

response = conn.publish_data_source(
datasource_file_path='superstore_extract.tdsx',
datasource_name='superstore_extract',
project_id=PROJECT_ID_TO_PUBLISH_TO)

Inspect the outcome: print(response.json())

Unlock the Power of Data Visualization with Our Tableau Course.

answered Mar 4, 2022 by Neha
• 9,020 points

Related Questions In Tableau

0 votes
1 answer

How to get Tableau results in python?

Well even I was looking for the ...READ MORE

answered Apr 9, 2018 in Tableau by ffdfd
• 5,550 points
862 views
0 votes
1 answer

How to refresh the extracted data source automatically in Tableau Desktop?

Hi AwesomeSauce, This comes up every so often!  Tableau ...READ MORE

answered Aug 14, 2018 in Tableau by Naruto
• 710 points
4,602 views
0 votes
1 answer

how to use/access Json data in Tableau?

Hi Sindhu, 1. Double click on Json on ...READ MORE

answered Mar 19, 2019 in Tableau by Cherukuri
• 33,030 points
3,784 views
0 votes
1 answer

How to replace the count(field) which is missing in data with zero in tableau?

Use calculated field to create a dummy ...READ MORE

answered Dec 21, 2019 in Tableau by sindhu
2,004 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,391 views
0 votes
1 answer
0 votes
1 answer

How to add same filter to multiple data sources in tableau server?

If numerous data sources have a field ...READ MORE

answered Apr 12, 2022 in Tableau by Neha
• 9,020 points
2,463 views
0 votes
1 answer

How to print projects and workbook names based on site id in tableau server client?

Here's how I do it once I've ...READ MORE

answered Mar 9, 2022 in Tableau by Neha
• 9,020 points
1,710 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP