---
title: "How to Export Custom Report Data Automatically"
url: "https://dm0bkdes5q7a2ls.productfruits.help/en/article/how-to-export-custom-report-data-automatically"
language: "en"
last_updated: "2026-03-16T15:10:42.943Z"
---

# How to Export Custom Report Data Automatically

To automate large data exports (generally, reports with more than 5000 rows) it is favorable to generate an export as a compressed consolidated CSV. A script is then used to download the most recent generated report defined by the report name.

> Note: The steps in this article require the following script (login required): [DownloadReportExportByName.py](https://spirionsdp.zendesk.com/hc/en-us/article_attachments/35308287143437)

## How to **Export Reporting Data**

### 1\. Create the Report

-   Define the columns for export using the [console UI](https://dm0bkdes5q7a2ls.productfruits.help/en/article/reporting-api) or by using a customized API queries.
-   -   See [How to Use the Reporting API](https://dm0bkdes5q7a2ls.productfruits.help/en/article/reporting-api)  
          
        ![](https://cdn-assets.productfruits.com/79012551-badc-44a9-8bdc-96f96d97ec33)

### 2\. Schedule Export 

-   Add a one-time export or schedule to the report.  
      
    ![](https://cdn-assets.productfruits.com/8758ae28-25c8-41a6-90af-2127ef7d7718)  
    **Pickup export**
-   Manual - In the Spirion Sensitive Data Platform console navigate to the **Custom Reports > Report Downloads** tab
-   Scripted - via [Python script](https://spirionsdp.zendesk.com/hc/en-us/article_attachments/35308287143437) or a custom script

**Extract, Transform, Load** (ETL) the CSV to your analytics system or data store.

## **Sample Script**

The [DownloadReportExportByName.py](https://spirionsdp.zendesk.com/hc/en-us/article_attachments/35308287143437) script available in the article "[Automating Export of Custom Reports Data](https://spirionsdp.zendesk.com/hc/en-us/articles/35308325583629-Automating-Export-of-Custom-Reports-Data)" on the Spirion Custom Support portal checks the **`GetReportHistories`** (API) or the Spirion console equivalent of **Custom Reports > Report Downloads** tab for the next export by report name.

-   If there are multiple reports with the same name available for download it selects the most recent.
-   If the report download link is not available it retries every 10 minutes for up to 3 days.  
      
    ![](https://cdn-assets.productfruits.com/f65a04e3-b072-4917-b9f4-a7de76eceda5)

### Script Considerations

-   Token Refresh is required if the script will run longer than 1 hour
-   If the report is still generating, check every so often for the download, but time out if many hours have passed.
-   Include the ability to pass the credentials and report name via command line as arguments to prevent credentials from being stored in scripts.

### Execute the Script with the Required Arguments

Execute the script from the command line or script execution platform.  
  
**Required Arguments**

-   \--server\_name
-   \--client\_id
-   \--client\_secret
-   \--report\_name

#### Example

```
.\DownloadReportExportByName.py --server_name yourConsoleServerName--client_id yourClientId --client_secret yourClientId --report_name reportName
```
