Skip to main content

CSVLoader

CSVLoader

Format-centric CSV loader for all CSV file data types. More…

#include <CSVLoader.hpp>

Inherits from IFormatLoader

Public Functions

Name
CSVLoader() =default
~CSVLoader() override =default
virtual LoadResult load(std::string const & filepath, DM_DataType dataType, nlohmann::json const & config) const override
Load a single data object from CSV file.
virtual bool supportsBatchLoading(std::string const & format, DM_DataType dataType) const override
Check if batch loading is supported for this format/type.
virtual BatchLoadResult loadBatch(std::string const & filepath, DM_DataType dataType, nlohmann::json const & config) const override
Load all data objects from a multi-series CSV file.
virtual LoadResult save(std::string const & filepath, DM_DataType dataType, nlohmann::json const & config, void const * data) const override
Save data to CSV file.
virtual bool supportsFormat(std::string const & format, DM_DataType dataType) const override
Check if this loader supports the format/dataType combination.
virtual std::string getLoaderName() const override
Get loader name for logging.
virtual std::vector< SaverInfo > getSaverInfo() const override
Return metadata for all save operations this loader supports.

Additional inherited members

Public Functions inherited from IFormatLoader

Name
virtual ~IFormatLoader() =default
virtual std::vector< LoaderInfo > getLoaderInfo() const
Return metadata for all load operations this loader supports.

Detailed Description

class CSVLoader;

Format-centric CSV loader for all CSV file data types.

This loader follows the format-centric architecture where one loader handles a specific file format (CSV) for all applicable data types.

Supported data types:

This loader supports batch loading for:

  • DigitalEvent CSV with identifier column (returns one series per identifier)
  • DigitalEvent CSV with multi_file=true (returns one series per file in a directory)
  • Points DLC format with all_bodyparts=true (returns one PointData per bodypart)
  • DigitalInterval with csv_layout=“binary_state” and all_columns=true (returns one series per column)

CSV Layouts for DigitalInterval:

  • “intervals” (default): Two columns with start/end times for each interval
  • “binary_state”: Rows represent time points, columns contain 0/1 state values. Intervals are extracted from contiguous regions where value >= threshold.

Configuration options vary by data type - see individual load methods for required and optional JSON configuration fields.

Public Functions Documentation

function CSVLoader

CSVLoader() =default

function ~CSVLoader

~CSVLoader() override =default

function load

virtual LoadResult load(
    std::string const & filepath,
    DM_DataType dataType,
    nlohmann::json const & config
) const override

Load a single data object from CSV file.

Reimplements: IFormatLoader::load

For multi-series CSV files (DigitalEvent with identifier, DLC with multiple bodyparts), this returns only the first object. Use loadBatch() for all objects.

function supportsBatchLoading

virtual bool supportsBatchLoading(
    std::string const & format,
    DM_DataType dataType
) const override

Check if batch loading is supported for this format/type.

Reimplements: IFormatLoader::supportsBatchLoading

Returns true for:

  • DigitalEvent with identifier column or multi_file=true
  • Points with DLC format and all_bodyparts=true
  • DigitalInterval with csv_layout=“binary_state” (multiple columns)

function loadBatch

virtual BatchLoadResult loadBatch(
    std::string const & filepath,
    DM_DataType dataType,
    nlohmann::json const & config
) const override

Load all data objects from a multi-series CSV file.

Reimplements: IFormatLoader::loadBatch

For DigitalEvent, returns one DigitalEventSeries per unique identifier or per file when multi_file is true. For Points with DLC format, returns one PointData per bodypart. For DigitalInterval with binary_state layout, returns one series per data column.

function save

virtual LoadResult save(
    std::string const & filepath,
    DM_DataType dataType,
    nlohmann::json const & config,
    void const * data
) const override

Save data to CSV file.

Reimplements: IFormatLoader::save

function supportsFormat

virtual bool supportsFormat(
    std::string const & format,
    DM_DataType dataType
) const override

Check if this loader supports the format/dataType combination.

Reimplements: IFormatLoader::supportsFormat

Supports format “csv” for Line, Points, Mask, Analog, DigitalEvent, DigitalInterval Supports format “dlc_csv” for Points (DLC/DeepLabCut format - legacy compatibility)

function getLoaderName

virtual std::string getLoaderName() const override

Get loader name for logging.

Reimplements: IFormatLoader::getLoaderName

function getSaverInfo

virtual std::vector< SaverInfo > getSaverInfo() const override

Return metadata for all save operations this loader supports.

Reimplements: IFormatLoader::getSaverInfo


Updated on 2026-11-13 at 20:25:41 +0000