Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
CSVReader Class Reference

CSV → DataFrame loader with basic type handling. More...

#include <CSVReader.h>

Public Member Functions

DataFrame read_csv (const std::string &filename, CSVOptions options=CSVOptions())
 Read a CSV file and construct a DataFrame.
 

Detailed Description

CSV → DataFrame loader with basic type handling.

CSVReader provides a single high-level method read_csv which:

  • reads a CSV file from disk,
  • uses the first line as a header (column names),
  • optionally interprets the first column as an index (see CSVOptions::hasIndex),
  • converts each cell to the column's declared type (int, double, std::string),
  • returns a fully constructed DataFrame with correct shape, columns and index set.

If a column type is not specified in CSVOptions::columnTypes, it defaults to double and the option map is updated accordingly.

Definition at line 36 of file CSVReader.h.

Member Function Documentation

◆ read_csv()

DataFrame CSVReader::read_csv ( const std::string &  filename,
CSVOptions  options = CSVOptions() 
)

Read a CSV file and construct a DataFrame.

The file is expected to have a header line with column names. Types and index behavior are controlled via the options argument:

  • options.hasIndex:
    • true → first column in the CSV is treated as an index column, values are stored in DataFrame::index and not as a data column.
    • false → rows are given a synthetic integer index ("0", "1", ...).
  • options.columnTypes:
    • if a column name appears in this map, its values are converted to the corresponding type (int, double, std::string),
    • otherwise the column is assumed to be double.

The returned DataFrame has its internal CSVOptions synchronized with the effective options used during parsing.

Parameters
filenamePath to the CSV file on disk.
optionsParsing options (column types, index presence).
Returns
A DataFrame containing the parsed CSV data.
Exceptions
std::runtime_errorIf the file cannot be opened.
std::invalid_argumentIf an unsupported column type is requested.

Definition at line 45 of file CSVReader.cpp.


The documentation for this class was generated from the following files: