TableauOps Automation Workshop: CSV to Hyper
Eric converts a CSV into a Hyper file with pandas and pantab, then publishes it to Tableau Cloud with Tableau Server Client and a personal access token, start to finish in one Python file.
The short version
This is Eric's first live workshop. He takes a CSV of customers, turns it into a Hyper file, and publishes that Hyper as a data source on Tableau Cloud. The whole thing is one Python file, one .env file, and the source CSV.
The stack is pandas to read the CSV, pantab to write the Hyper, python-dotenv to keep credentials out of the script, and Tableau Server Client to sign in with a personal access token and publish. He walks each cell in VS Code, shows the token setup in Tableau Cloud, and opens the published data source to check it.
The case for Hyper: faster data sources, smaller files, and a published source that any workbook can connect to instead of a loose file. His demo CSV was too small to show much size gain, and the subscription date did not come through as a date, which he points out on screen.
The breakdown
Hyper beats a CSV on speed, size, and reuse
Eric gives three reasons to convert. Hyper data sources are quicker. They are smaller, and he has seen his own CSVs drop to about half the size once converted. And once the Hyper is published to Tableau Server or Cloud, other workbooks can connect to it without anyone handling external files.
He comes back to size at the end. His demo file was small, so the gain was minor, but he cites benchmarks claiming the Hyper can be as little as 15% of the original CSV. He has not run speed benchmarks himself.
Credentials belong in a .env file, never in the script
Every script he writes starts with a .env file. It holds the server URL, site ID, token name, token secret, CSV path, and output Hyper name, and the script reads them with os.getenv. That way he can share the script or stream it without exposing a username, password, or secret.
One tip: .env values can get cached. If you change the file and are not sure the change landed, print a value that is safe to show, like the server URL, rather than the secret.
A personal access token replaces your username and password
In Tableau Cloud he goes to My Account Settings, scrolls to Personal Access Tokens, names one CSV to Hyper, and creates it. If tokens are disabled on your site, that section is greyed out. He knows site admins and creators can create them and is not sure about viewers.
The secret is shown once. After you click Done it is not available anywhere again, so save it first. The token can pull and publish data and workbooks and read user details, so treat the secret like a password. His token showed a one year expiry.
pantab handles data types better than the raw Hyper API
After reading the CSV into a pandas DataFrame and checking df.head, he writes the Hyper with pantab. Everything can be done with the Tableau Hyper API, but he finds pantab does a better job keeping types like dates intact on the way from CSV to Hyper.
Some errors do not show up in the VS Code output. When that happens, check the Hyper log file that gets written next to your Hyper.
Tableau Server Client starts with an auth object and a server object
With TSC aliased as tsc, he builds a PersonalAccessTokenAuth from the token name, secret, and site ID, then a tsc.Server from the URL. The site ID is the site portion of your Cloud URL. On Server, the URL is whatever you use to reach your server.
Signing in with the two together is the starting point for every TSC process. He prints the auth and server objects to show what they hold.
List projects first so the target name is exact
server.projects.get returns every project, and he loops over them to print the names: default, Samples, External Assets, and Admin Insights. He sets the target to default.
Publishing needs a project ID, not a name, so the script searches the project list for the name and grabs its ID. If the name is not on the site, it raises an error that says so.
Publish with Overwrite to keep revision history and connections
He builds a DatasourceItem with the project ID and calls server.datasources.publish with the Hyper path and a publish mode. He tends to use Overwrite, including when he refreshes a data source outside Tableau and republishes it. Overwrite keeps Tableau's native revision history and keeps connected workbooks connected.
Overwrite also creates the data source if it does not exist, so it will not error. The catch is that it will replace anything with the same name in that project.
Open the published source and check it before you trust it
In Explore, under all data sources, the new customers source is there, owned by him. Whoever owns the token becomes the owner of whatever it publishes. The table shows the Hyper's default schema name.
He starts a new workbook on it to confirm everything came through, and finds the subscription date did not land as a date, possibly because of its format. He also shows that the same get call works for workbooks and data sources by swapping the endpoint, and at 30:37 revokes the token and shows the next sign-in failing with an invalid PAT error.
Key takeaways
- Converting CSVs to published Hyper data sources makes them faster, smaller, and reusable from any workbook.
- Keep server, site, and token values in a .env file and read them with os.getenv so scripts are safe to share.
- Save a personal access token secret before clicking Done, because Tableau never shows it again.
- pantab keeps data types like dates more reliably than writing the Hyper by hand, but still check the result.
- Publish with Overwrite to keep revision history and workbook connections, and know it replaces same-named sources.
- Revoke tokens you no longer need; a revoked PAT fails sign-in immediately.
Watch this when
You have CSVs feeding Tableau workbooks and want a script that turns them into published Hyper data sources on Tableau Cloud or Server.
Mentioned in this video
- 5:20TableauOps ↗
Eric's learning site for the Tableau APIs
- 7:26Tableau Server Client (Python) ↗
Used for PAT sign-in, listing projects, and publishing
- 15:53pantab ↗
Writes the pandas DataFrame to Hyper
- 16:02Tableau Hyper API ↗
The alternative to pantab for writing Hyper files
- 33:35Tableau Document API ↗
Answer to a question about pulling sheet and data source details from a workbook
- 33:46Tableau Metadata API ↗
Another way to read workbook and data source details on Server or Cloud
- Tableau Server Client lessons →
More on working with TSC