GET checks into CSV files

Use a Python and the Soda Cloud API to retrieve check and dataset info from a Soda Cloud account and populate CSV files.

This example Python script uses Pandas and the Soda Cloud API to retrieve information from your Soda Cloud account and prepare two CSV files:

  • one file contains information about all the datasets in your Soda Cloud account

  • one file contains a list of all the checks in your Soda Cloud account, including a column attributes you may have added to checks

✖️ Requires Soda Core Scientific (included in a Soda Agent) ✖️ Supported in Soda Core ✔️ Supported in Soda Cloud + Soda Library ✔️ Supported in Soda Cloud + Soda Agent

Prerequisites

  • You have set up a Soda Cloud account and have connected to a data source via Soda Library or a Soda-hosted or self-hosted Soda Agent.

  • You have prepared at least one data quality check and have run at least one Soda scan in Soda Cloud.

  • You have Admin privileges in your Soda Cloud account which gives you permission to access to the account and all its checks and datasets via the API.

Set up and run

  1. Best practice dictates that you use a virtual environment to execute the script. Use the following commands to create and activate a venv, then upgrade pip and install pandas. MacOS:

python -m venv .sodaapi 
source .sodaapi/bin/activate 
pip install --upgrade pip  
pip install requests pandas

Windows:

python -m venv .sodaapi
source .sodaapi\Scripts\activate
python.exe -m pip install --upgrade pip
python.exe -m pip install requests pandas
  1. Create a new Python file called api2csv.py, then copy the script below into the file.

  2. In the # Soda Cloud account section of the file, replace the placeholder values with your own Soda Cloud URL and API key values. See Generate API keys for instructions on how to create new keys.

  3. If you wish, change the value of file_type in the script to json if you prefer that type of output over CSV.

  4. Run the script! It saves the new files to the same directory as your api2csv.py file.

Output:

API to CSV script

Go further

Need help? Join the Soda community on Slack.

Last updated

Was this helpful?