tableau / document-api-python

Create and modify Tableau workbook and datasource files
https://tableau.github.io/document-api-python/
MIT License
326 stars 178 forks source link

Replace Extract in Packaged Workbook #102

Open turnercj65 opened 7 years ago

turnercj65 commented 7 years ago

I'm trying to figure out how to replace an extract in a packaged workbook with a different extract that has the same table definition. I can use the Tableau SDK to create a new .tde, but it looks like there aren't python methods to replace an extract in a packaged workbook.

I'm imagining this would look something like this:

from tableaudocumentapi import Workbook

sourceWB = Workbook('workbook.twbx')
sourceWB.datasources[0].connections[0].extract = "MY-NEW-EXTRACT.tde"
#OR sourceWB.datasources[0].connections[0].extract.package('new-extract.tde')

sourceWB.save_as('new_workbook.twbx')

I can replace an extract in a .twb file by hacking the xml and changing references, but the "save_as" method doesn't actually package the workbook so that the connection is no longer dependent on a .tde file.

t8y8 commented 7 years ago

Marking this as an enhancement.

This requires:

@turnercj65 thanks for submitting this idea with some sample code, it really helps with planning out how things could feel for our users!

Question, do you have any thoughts on what kind of 'extract options' you might want to apply? (Like the filter dialog, incremental/full, etc)

turnercj65 commented 7 years ago

Hey Tyler,

Thanks for reviewing this!

Regarding the extract options, in my scenario the tde was already generated, so these options wouldn't apply in my mind. (Unless you were extracting the extract)

I could see extract options coming in handy if you could change a data source from live to an extract, then it would be good to have the same capabilities you have in desktop, but my enhancement request is really just dealing with using an already generated extract. Does that make sense?

t8y8 commented 7 years ago

It does, thank you for the suggestion!

We'll take a look (Note we also welcome PRs 😄 )

turnercj65 commented 7 years ago

This particular request would enable me to do what I describe below, but I'd have to make use of the Tableau SDK to generate an extract.

As a more ideal personal request goes, this would be super cool:

Modify a workbook that has a live connection to an excel file by changing the connection string to a different excel document. Then be able to extract the data and package the workbook as a twbx so that it is no longer dependent on the excel document. All with the document api. Mad props if you can make that happen!