Class CsvDataExporter
Defined in File csv_data_exporter.hpp
Base Type
public holoscan::DataExporter
(Class DataExporter)
-
class CsvDataExporter : public holoscan::DataExporter
A class to support exporting Holoscan application data in CSV format for Holoscan Federated Analytics.
The directory will be created with the app name in the data root directory if it is not present already. Inside the application directory, a directory with the current timestamp will be created.
The output file name can be specified using the environment variable
HOLOSCAN_ANALYTICS_DATA_FILE_NAME
. If not specified, the output file nameddata.csv
will be created inside the timestamp directory. The column names are added to the output file as a first row.Using this class mainly involves two steps:
Create
<a class="reference internal" href="#classholoscan_1_1CsvDataExporter" target="_self">CsvDataExporter</a>
object specifying app name and columns.Call
<a class="reference internal" href="#classholoscan_1_1CsvDataExporter_1acb62b4b99c98762c6d46a033e7990095" target="_self">export_data()</a>
method to add a single row to the output file.
Example:
#include "holoscan/core/analytics/csv_data_exporter.hpp" void export_data() { const std::string app_name = "sample_app"; const std::vector<std::string> columns = {"column1", "column2", "column3"}; CsvDataExporter data_exporter(app_name, columns); const std::vector<std::string> data = {"1", "2", "3"}; data_exporter.export_data(data); ... }
Public Functions
-
CsvDataExporter(const std::string &app_name, const std::vector<std::string> &columns)
The constructor creates required directories and CSV file with the specified names.
- Parameters
app_name – The application name.
columns – The column names list which will be added to the CSV file as a first row.
-
~CsvDataExporter()
-
virtual void export_data(const std::vector<std::string> &data) override
Exports given data to a CSV file.
Each call to the function will add one more row to the csv file.
- Parameters
data – The data to be written to the CSV file.
-
inline const std::string &output_file_name() const
Returns output file name.
-
inline const std::vector<std::string> &columns() const
Returns the column names.
Public Static Functions
-
static expected<std::string, ErrorCode> get_analytics_data_file_name_env()
Get the value of analytics output file name environment variable
HOLOSCAN_ANALYTICS_DATA_FILE_NAME
.- Returns
A string if the environment variable is set else it returns error code.