Download Tableau dashboard PDFs like a boss using Python

  Рет қаралды 12,713

Devyx

Devyx

Күн бұрын

Пікірлер: 58
@raphaelpavan6540
@raphaelpavan6540 2 жыл бұрын
Thankkkss a lot. Only hard time I had was to set up the connection... Took me days! But now, I am flying on sending tableau emails!
@lottohan-ni-ely
@lottohan-ni-ely Жыл бұрын
That's exactlty what i'm trying to do? can you please share me a script that will cycle through the filters? that is, for this example, generating pdf for each region in each year? .. thank you, im not a programmer
@zibrawr4775
@zibrawr4775 3 жыл бұрын
Great tutorial! Do you know how I can save the pdf to a specific file location?
@zibrawr4775
@zibrawr4775 3 жыл бұрын
Or how to run through a list of workbooks and print them all out?
@devyx
@devyx 3 жыл бұрын
@@zibrawr4775 to save to a file location is the generic python pattern: with open("path/to/your/file.pdf", "wb") as f: f.write(response.content) That is, assuming you stored the response of your API call to download the PDF into a variable named "response".
@devyx
@devyx 3 жыл бұрын
@@zibrawr4775 if you have a list of view ids you can loop through them, download the PDFs for each, and write them to any location you specify. You can even use some Python PDF libraries to merge the PDF files if you want.
@nikitakandpal87
@nikitakandpal87 5 ай бұрын
Hey, I have embedded links in one of the fields in my tableau dashboard. How can I download the pdf with the embedded links. I am only seeing a static text for the URLs. Please help.
@niravdedhia878
@niravdedhia878 7 ай бұрын
Thank You for the helpful video. Can you please help me understand how to pass year and month in python? Tableau filter has Month and Year populated
@avanibhatnagar23
@avanibhatnagar23 2 жыл бұрын
Do you have a syntax for max_age parameter here to avoid caching? My pdfs are called over and over again and they are caching and returning old data. I tried this and it still returns old data: pdf_params = {"filter_company": f"vf_{tableau_company_name_field}={tableau_company_name_value}", "maxAge":"0"} I had to make the age a string because it failed with it being an int. Any idea?
@frederikgrieb5476
@frederikgrieb5476 3 жыл бұрын
Thanks very helpful! Do you know if its possible to download custom view instead of original (default view) view?
@devyx
@devyx 3 жыл бұрын
Hi Frederik, unfortunately I don't think those custom views are stored under a query-able view ID and so as far as the REST API is concerned they don't exist. I'd love to be proven wrong, but that is my understanding.
@vamsikrishna1066
@vamsikrishna1066 3 жыл бұрын
very nice. how to down load all pdfs at a time with two filter option
@Nerd4141
@Nerd4141 Жыл бұрын
How to download a view from tableau as image and make it as pdf using python from a specific workbook i need code please
@AdreenaBurhan
@AdreenaBurhan Жыл бұрын
Is there a way to include Marks Card settings as a filter for the image?
@devyx
@devyx Жыл бұрын
For the REST API endpoints, I'm not seeing anything in Tableau's API documentation for the "Query View PDF" endpoint supporting marks card settings. But perhaps you can dig in and see if there's anything along the lines of what you're looking for, I would check: * Tableau REST API reference * Tableau JavaScript API reference Some of the JavaScript API functionality goes a bit more advanced... though I expect to interact with the marks card you may need to download the workbook itself, unzip the twbx file, and then edit the workbook's XML (twb file) to gain access to (or control) marks card properties.
@yashshah1316
@yashshah1316 2 жыл бұрын
Amazing Tutorial. Is there a way to pass the URL itself to download the pdf? Instead od creating param variables and filters?
@devyx
@devyx 2 жыл бұрын
Hey Yash, yes after you perform the sign in action successfully you are free to attempt any combination of endpoint URL, request payload, and headers. For example: self.active_endpoint = "whatever URL.com" self.active_headers = self.default_headers self.active_request = None
@prateekf47
@prateekf47 2 жыл бұрын
Great tutorial! I'm facing issue when downloading the pdf, the conn.active_enpoint shows the filters accurately, but the downloaded file does not have right filters. Any suggestions to troubleshoot this ? Thanks !
@devyx
@devyx 2 жыл бұрын
Hey Prateek, this usually is related to your fields or values containing characters which are not URL-friendly. For example, if you have a field "country" and one value is "South Africa" then your filter should convert to the URL-friendly form of "South%20Africa", where %20 is how spaces are represented in URL-friendly text. You can use the urllib.parse.quote function to cast any given text into a URL-friendly representation. Hope that helps!
@debasis2
@debasis2 Жыл бұрын
How can I retrieve applied existing filters and parameters information from the dashboard by the end user and then perform a pdf download for the worksheet(text table) rather than an entire table with default settings? Can the REST APIs be more interactive like the way we have it in Javascript REST API viz.getWorkbook().getActiveSheet().getWorksheets().get("Sheet").getFiltersAsync() Is it possible through REST APIs ?
@divinorum-gaming
@divinorum-gaming Жыл бұрын
Looking at Tableau's REST API reference, there is not a 1:1 mapping of functionality you have in the JavaScript API. For example, I do not see a REST API endpoint which would tell you the available values populated in a parameter/filter. I recommend searching through the REST API reference to know which endpoints are supported.
@jermritdeeprom6370
@jermritdeeprom6370 2 жыл бұрын
Thank you for a detailed explanation. Just wondering how to pass png parameters for height and width? Here is the example I use for pdf parameters. # pdf_params = { # "pdf_orientation":"orientation=Portrait", # "pdf_layout": "type=A4", # }
@briarcarlisle8080
@briarcarlisle8080 11 ай бұрын
Does filtering work when there are multiple data sources connecting to a tableau dashboard? I am unable to get this to work, as the dashboard I am connecting to is blending data from a secondary data source.
@divinorum-gaming
@divinorum-gaming 11 ай бұрын
If you have a parameter set up that controls filters in both datasources then you should be able to control the parameter via view filtering, and in that way filter one or more datasources.
@briarcarlisle8080
@briarcarlisle8080 11 ай бұрын
Thanks for the reply, any thoughts on how to return a screenshot with multiple values selected within a single filter? For example, if I have a filter in Tableau called "Color" and there are 10 different drop down colors available to select, how do I get it to pull back a screenshot showing "Red" and "Blue" values? This is only pulling back Red values color_value = "Red, Blue" "filter_color": f"vf_{color}={color_value}", @@divinorum-gaming
@divinorum-gaming
@divinorum-gaming 11 ай бұрын
@@briarcarlisle8080 A couple things to consider here: 1) Remove the white space ("Red,Blue" instead of "Red, Blue") as the space character becomes '%20' in the eventual URL text. 2) Confirm that the underlying values are actually 'Red' and 'Blue'. If you alias or rename a field (or its values) in a Tableau workbook, you'll want to reference the "true" names when passing filters. Not to get into the weeds, but the way the REST API interacts with the underlying assets behind the scenes ignores the aliases and interacts with the raw data under the hood.
@gauravkumarpawar8386
@gauravkumarpawar8386 6 ай бұрын
Thank you for information 🎉🎉 Any idea how to download multiple dashboard tabs as single pdf file
@groggymoose2826
@groggymoose2826 4 ай бұрын
I have been downloading them separately and then using the pypdf library to join them into a single file.
@unhandledexception1948
@unhandledexception1948 6 ай бұрын
this is exactly, what I need.... is the code anywhere I can download ?
@olgakutcenko6401
@olgakutcenko6401 2 жыл бұрын
Thanks a lot for your videos, I am bindge watching them. I have a question: Do you know how I could download a workbook as .twb or .twbx (without knowing wheather it is .twb or .twbx format)?Thanks a lot!
@devyx
@devyx 2 жыл бұрын
If you don't know either way, then I'd recommend going with .twbx every time. It's really just a .zip file that you can unzip if you need to unpack the .twb file (which is really just an XML file). Try it out on a sample of your workbooks. I don't think I ever encountered an issue where downloading as .twbx caused a problem.
@santhanamanimaran355
@santhanamanimaran355 2 жыл бұрын
Can we download csv from tableau online instead of tableau server?
@devyx
@devyx 2 жыл бұрын
Yes, in the same way as shown here. It's the same API -- on Tableau Online you don't have certain endpoints available (such as the 'Create Site' endpoint). You can see which endpoints are supported by Tableau Online on the Tableau REST API reference.
@clarereshma6383
@clarereshma6383 3 жыл бұрын
Nice work ... Can u make a video to download ppt if possible
@devyx
@devyx 3 жыл бұрын
Hi Reshma, a few others have asked this same question so I am making this my next video. It will be published on Monday (2021-06-14)!
@mazeenmuhammed
@mazeenmuhammed 3 жыл бұрын
When i download image or pdf its downloaded in mobile view. how do i convert it to desktop view and download?
@devyx
@devyx 3 жыл бұрын
The device layout is not a property that can be specified when hitting the Tableau REST API endpoints. I would check the workbooks that you have published, and it is possible that your default setting is for mobile. It's possible that you need to republish your workbook with the default as 'Desktop' in order for the REST API queries to fetch images / PDFs of your desktop view. Worst case scenario, if you need to maintain a default as 'Mobile' layout for your business users, you can publish another version of the workbook whose default is 'Desktop' and use that as the object you point to for your REST API queries to download images and PDFs.
@mazeenmuhammed
@mazeenmuhammed 3 жыл бұрын
@@devyx Thanks for your quick response. I asked my tableau team they say its desktop as default but because of my screen resolution it opens by default in tablet mode may be. so i am not really sure about that.
@devyx
@devyx 3 жыл бұрын
​@@mazeenmuhammed Could it be that you're getting the desktop version, but you're seeing it in its narrow 'Portrait' PDF format? Using tableau-api-lib's query_view_pdf() method, you can pass in a "parameter_dict". You can use this to specify that you want the PDF in "Landscape" instead of "Portrait". Something like this: pdf_params = { 'type': 'type=A4', 'orientation': 'orientation=Landscape', 'filter': None } response = conn.query_view_pdf(view_id=, parameter_dict=pdf_params)
@mazeenmuhammed
@mazeenmuhammed 3 жыл бұрын
@@devyx I tried . It downloads only in landscape mode. :(
@devyx
@devyx 3 жыл бұрын
@@mazeenmuhammed Ah, that's too bad. If possible, I'd try downloading the workbook from Tableau Server and opening it up in Tableau Desktop just to verify that the developer was right about the default setting within the workbook. Can't hurt to double check!
@cargouvu
@cargouvu 3 жыл бұрын
Is it possible to do same with a dashboard parameter? The parameter would replace the filter.
@devyx
@devyx 3 жыл бұрын
Yes you can use parameters and filters in the exact same way to filter & query your Tableau view.
@cargouvu
@cargouvu 3 жыл бұрын
@@devyx can you post to tableau public? And github? Also, does this work for batch .pdf downloads??
@devyx
@devyx 3 жыл бұрын
​@@cargouvu As far as I know you cannot use the endpoints documented in the Tableau REST API against the Tableau Public server. It does appear you can download a PNG image of a Tableau Public workbook, but from what I can tell filtering is not supported. This link has some information about endpoints you can hit related to Tableau Public: github.com/wjsutton/tableau_public_api You can use tableau-api-lib to download PDF and workbook files. The logic for looping through your content to download the individual files is left to you. The REST API endpoint "Query View PDF" is implemented in tableau-api-lib with the method `query_view_pdf()`. tableau-api-lib does not support pushing content to GitHub. You would use this library to make use of Tableau's REST API to download or publish your desired content, and then what you do with that content (such as push to GitHub) is logic you build to support your unique situation.
@cargouvu
@cargouvu 3 жыл бұрын
@@devyx didn't get the piece about query_view pdf? Is this what's used to loop? Really new to all this so not sure how to put it together. Like you write in your blog, need to deliver for work.
@devyx
@devyx 3 жыл бұрын
@@cargouvu In this tutorial, we use the tableau-api-lib library first to establish a connection with our Tableau environment. That connection is maintained in a variable named `conn`. When in the tutorial we download the view's PDF, we do so by using the "Query View PDF" endpoint. This endpoint is implemented in the tableau-api-lib library with a method named `query_view_pdf`. So what I was saying in the previous comment is that you use the `query_view_pdf` method to download your PDF: response = conn.query_view_pdf() Here's a written step by step tutorial I have that demonstrates such a process end to end: medium.com/snake-charmer-python-and-analytics/step-by-step-custom-tableau-dashboard-pdf-bursting-e2f1f0f9ec39
@eclairesstudio7608
@eclairesstudio7608 3 жыл бұрын
Is that possible to download as ppt too 🙄
@devyx
@devyx 3 жыл бұрын
Hey Clare, yes you can download a .pptx file using the REST API's `Download Workbook PowerPoint` endpoint: help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_workbooks_and_views.htm#download_workbook_powerpoint In the tableau-api-lib, this endpoint is supported by the `download_workbook_powerpoint()` method.
Triggering Tableau extract refreshes using the REST API
17:38
SIZE DOESN’T MATTER @benjaminjiujitsu
00:46
Natan por Aí
Рет қаралды 8 МЛН
Players push long pins through a cardboard box attempting to pop the balloon!
00:31
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 44 МЛН
小路飞和小丑也太帅了#家庭#搞笑 #funny #小丑 #cosplay
00:13
家庭搞笑日记
Рет қаралды 15 МЛН
Take Command with Tabcmd
49:54
Tableau
Рет қаралды 19 М.
Request API data using Python in 8 minutes! ↩️
8:34
Bro Code
Рет қаралды 30 М.
I Analyzed My Finance With Local LLMs
17:51
Thu Vu data analytics
Рет қаралды 497 М.
Replace Excel Vlookup with Python - Five Minute Python Scripts
6:33
Derrick Sherrill
Рет қаралды 230 М.
SIZE DOESN’T MATTER @benjaminjiujitsu
00:46
Natan por Aí
Рет қаралды 8 МЛН