Workaround for writing csv outputs from your Tableau Cloud Prep flows to local directories
This post is for users of the Cloud version of Tableau Prep who wish they could save CSV files to a local directory.
Here is a link to the code referenced in this post, as well as a corresponding video walkthrough.
Tableau Prep Builder supports three primary output options for your flow results:
output as a published data source to a Tableau Cloud or Server site
write back the results to a database
write the results to a local directory — either as a csv or a hyper file
However, if you run Tableau Prep directly on Tableau Cloud, you lose the option to save the output as a csv in a local directory.
One potential way to overcome this limitation is to setup a script that runs after a Tableau Prep flow executes — this script would pull down the published data source (i.e. download the tdsx file), unzip the tdsx file to access the corresponding hyper file, and build and save a csv file from that hyper file.
Here is a Google Colab link to a notebook that runs through these steps.
While not included in my example, this code could either be triggered via webhook or scheduled using a cron job or task scheduler.
The overall steps include:
1. Authenticate into the REST API via Connected Apps
3. Download desired data source
4. Extract hyper file from data source with hyper api
5. Read in hyper file into Pandas DataFrame
6. Download DataFrame as csv
Alternative option:
If the approach that I outlined doesn’t work for you, you could also write your output to a database, then implement a process to pull down a csv from the db.
Thanks for reading and hope this was helpful.