This is the source code for the python project that adds a DEFINITIONS datasource via drag and drop
It uses PyInstaller to create the TableauModifier.EXE file.
The underlying code works by
- Taking in a Workbook (twb or twbx) using sys.argv[1]
- Using the tableaudocumentapi library to scan the workbook and create an array with all fields in use
- Writing a query that uses the newly created array as part of it's WHERE statement
- Using the tableau_tools libarary to create a datasource called "DEFINITIONS" using the query
- Create a copy of the original workbook called "Modified Workbook" and add the "DEFINITIONS" datasource to it.
Known Bugs:
- Occasionally it will fail to read the initial workbook, I believe this is a bug with the tableaudocumentapi library.