{"id":24681,"library":"tableaudocumentapi","title":"Tableau Document API","description":"A Python module for working with Tableau workbook (TWB) and datasource (TDS) files, including packaged formats (TWBX, TDSX). It allows programmatic editing of connections, fields, dashboards, sheets, and custom SQL. Current version 0.11, with occasional releases.","status":"active","version":"0.11","language":"python","source_language":"en","source_url":"https://github.com/tableau/document-api-python","tags":["tableau","data-visualization","workbook","datasource","xml","api"],"install":[{"cmd":"pip install tableaudocumentapi","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Server class is in tableauserverclient, not tableaudocumentapi.","wrong":"from tableaudocumentapi import Server","symbol":"Server","correct":"from tableauserverclient import Server"},{"note":"","wrong":"","symbol":"Workbook","correct":"from tableaudocumentapi import Workbook"},{"note":"","wrong":"","symbol":"Connection","correct":"from tableaudocumentapi import Connection"}],"quickstart":{"code":"from tableaudocumentapi import Workbook\n\nwb = Workbook('sample.twbx')\nfor ds in wb.datasources:\n    for conn in ds.connections:\n        print(f'DB: {conn.dbname}, Server: {conn.server}')\n        conn.server = 'new-server.example.com'\nwb.save_as('output.twbx')","lang":"python","description":"Open a Tableau packaged workbook, inspect and modify database connections, then save as a new file."},"warnings":[{"fix":"Upgrade to 0.7+ which fixed namespace preservation, or verify saved file opens correctly in Tableau.","message":"Saving a workbook modifies namespaces; if you open and save a file without changes, the XML namespace may change, causing Tableau to treat it as a different version. Always test saved files.","severity":"breaking","affected_versions":"<0.7"},{"fix":"Monitor temp space; use tempfile.gettempdir() to check location.","message":"Packaged (twbx/tdsx) files are zipped; the library extracts them to a temporary directory. Ensure sufficient disk space and that the temporary directory is writable.","severity":"gotcha","affected_versions":"all"},{"fix":"Only use documented properties (see class attributes).","message":"The library does not support editing of dashboard layout or worksheet calculations. Attempting to modify dashboard objects may silently fail.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install tableaudocumentapi' in the correct Python environment.","cause":"Package not installed or installed in wrong environment.","error":"ModuleNotFoundError: No module named 'tableaudocumentapi'"},{"fix":"Upgrade to latest version (pip install -U tableaudocumentapi) and ensure you import Workbook from tableaudocumentapi.","cause":"Using older version (<0.5) without save_as method, or imported wrong module.","error":"AttributeError: 'Workbook' object has no attribute 'save_as'"},{"fix":"Verify file is a valid Tableau workbook/datasource. Try opening in Tableau Desktop to confirm integrity.","cause":"Attempting to open a corrupt or non-Tableau XML file, or the file is not a valid TWB/TDS.","error":"xml.etree.ElementTree.ParseError: not well-formed (invalid token)"},{"fix":"Set TMPDIR environment variable to a writable directory, or run with appropriate privileges.","cause":"Insufficient permissions to write to the temporary directory (common on restrictive systems).","error":"PermissionError: [Errno 13] Permission denied: '/tmp/tmpxxx/...'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}