> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sdk-user-guide/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sdk-user-guide/_mcp/server.

# holoscan::DataExporter

> A base class to support exporting Holoscan application data for Federated Analytics.

A base class to support exporting Holoscan application data for Federated Analytics.

This class will create a directory with the application name passed to the constructor. It will also create a subdirectory based on the current timestamp within the application directory.

The root directory for the application data can be specified by using environment variable `HOLOSCAN_ANALYTICS_DATA_DIRECTORY`. If not specified, it will default to current application directory.

```cpp showLineNumbers={false}
#include <holoscan/data_exporter.hpp>
```

---

## Constructors

### DataExporter \[#dataexporter]

```cpp showLineNumbers={false}
holoscan::DataExporter::DataExporter(
    const std::string &app_name
)
```

### Destructor \[#destructor]

### \~DataExporter

```cpp showLineNumbers={false}
virtual holoscan::DataExporter::~DataExporter() = default
```

---

## Methods

### export\_data \[#exportdata]

```cpp showLineNumbers={false}
virtual void holoscan::DataExporter::export_data(
    const std::vector<std::string> &data
)
```

A pure virtual function that needs to be implemented by subclasses to export the data in required format.

**Parameters**

**`data`** `const std::vector<std::string> &`

The data to be written to the CSV file.

---

### app\_name \[#appname]

```cpp showLineNumbers={false}
const std::string & holoscan::DataExporter::app_name() const
```

Return the application name.

### data\_directory \[#datadirectory]

```cpp showLineNumbers={false}
const std::string & holoscan::DataExporter::data_directory() const
```

Returns a data directory name.

### cleanup\_data\_directory \[#cleanupdatadirectory]

```cpp showLineNumbers={false}
void holoscan::DataExporter::cleanup_data_directory()
```

Remove the data directory and its contents.

### create\_data\_directory\_with\_timestamp \[#createdatadirectorywithtimestamp]

```cpp showLineNumbers={false}
void holoscan::DataExporter::create_data_directory_with_timestamp()
```

Create a data directory with the current timestamp inside the application directory.

---

## Static methods

### get\_analytics\_data\_directory\_env \[#getanalyticsdatadirectoryenv]

```cpp showLineNumbers={false}
static expected<std::string, ErrorCode> holoscan::DataExporter::get_analytics_data_directory_env()
```

Get the value of analytics data directory environment variable `HOLOSCAN_ANALYTICS_DATA_DIRECTORY`.

**Returns:** A string if the environment variable is set else it returns error code.

---

## Member variables

| Name              | Type          | Description |
| ----------------- | ------------- | ----------- |
| `app_name_`       | `std::string` |             |
| `directory_name_` | `std::string` |             |