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 in Tableau by Vaani
• 5,040 points
56 views

1 answer to this question.

0 votes

https://www.tableautim.com/playlist-video/tableau-tds-and-tdsx-files/csv-to-tdsx

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())

For more information: https://medium.com/snake-charmer-python-and-analytics/how-to-publish-tableau-tdsx-data-source-files-using-python-ab576a9bef4c

answered Mar 4 by Neha
• 6,260 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 sdfg
• 5,550 points
280 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
3,601 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,010 points
2,032 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
1,280 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 2,756 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 in Tableau by Neha
• 6,260 points
37 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP