Vince's CSV Parser
Loading...
Searching...
No Matches
csv::DataFrame< KeyType > Class Template Reference

Classes

struct  const_row_accessor
 
struct  mutable_row_accessor
 

Public Types

using row_type = DataFrameRow< KeyType >
 
using column_type = DataFrameColumn< KeyType >
 
using iterator = internals::indexed_proxy_iterator< DataFrame< KeyType >, DataFrameRow< KeyType >, mutable_row_accessor >
 Row-wise iterator over DataFrameRow entries.
 
using const_iterator = internals::indexed_proxy_iterator< const DataFrame< KeyType >, DataFrameRow< KeyType >, const_row_accessor >
 Row-wise const iterator over DataFrameRow entries.
 
using DuplicateKeyPolicy = DataFrameOptions::DuplicateKeyPolicy
 

Public Member Functions

 DataFrame ()=default
 Construct an empty DataFrame.
 
 DataFrame (CSVReader &reader)
 Construct an unkeyed DataFrame from a CSV reader.
 
 DataFrame (csv::string_view filename, CSVFormat format=CSVFormat::guess_csv())
 Construct an unkeyed DataFrame directly from a CSV file.
 
 DataFrame (std::vector< CSVRow > rows)
 Construct an unkeyed DataFrame from an existing batch of rows.
 
 DataFrame (CSVReader &reader, const DataFrameOptions &options)
 Construct a keyed DataFrame from a CSV reader with options.
 
 DataFrame (csv::string_view filename, const DataFrameOptions &options, CSVFormat format=CSVFormat::guess_csv())
 Construct a keyed DataFrame directly from a CSV file.
 
 DataFrame (CSVReader &reader, const std::string &_key_column, DuplicateKeyPolicy policy=DuplicateKeyPolicy::OVERWRITE, bool throw_on_missing_key=true)
 Construct a keyed DataFrame using a column name as the key.
 
template<typename KeyFunc , csv::enable_if_t< csv::is_invocable_returning< KeyFunc, KeyType, const CSVRow & >::value, int > = 0>
 DataFrame (CSVReader &reader, KeyFunc key_func, DuplicateKeyPolicy policy=DuplicateKeyPolicy::OVERWRITE)
 Construct a keyed DataFrame using a custom key function.
 
template<typename KeyFunc , csv::enable_if_t< csv::is_invocable_returning< KeyFunc, KeyType, const CSVRow & >::value, int > = 0>
 DataFrame (CSVReader &reader, KeyFunc key_func, const DataFrameOptions &options)
 Construct a keyed DataFrame using a custom key function with options.
 
size_t size () const noexcept
 Get the number of rows in the DataFrame.
 
bool empty () const noexcept
 Check if the DataFrame is empty (has no rows).
 
size_t n_rows () const noexcept
 Get the number of rows in the DataFrame.
 
size_t n_cols () const noexcept
 Get the number of visible columns in the DataFrame.
 
bool has_column (const std::string &name) const
 Check if a column exists in the DataFrame.
 
int index_of (const std::string &name) const
 Get the index of a column by name.
 
const std::vector< std::string > & columns () const noexcept
 Get the column names in order.
 
void insert_row (size_t index, const std::vector< std::string > &row)
 Insert a new row at the specified index.
 
void insert_column (size_t index, const std::string &name)
 Insert a new column with empty values.
 
void insert_column (size_t index, const std::string &name, const std::string &default_value)
 Insert a new column with a default value.
 
void append_column (const std::string &name)
 Append a new column with empty values.
 
void append_column (const std::string &name, const std::string &default_value)
 Append a new column with a default value.
 
DataFrame selected_rows (const std::vector< std::uint8_t > &include_rows) const
 Build an unkeyed DataFrame containing rows whose corresponding mask entry is true.
 
bool try_insert_row (size_t index, const std::vector< std::string > &row, CSVError &error)
 Insert a row; validation failures leave the frame unchanged.
 
bool try_insert_column (size_t index, const std::string &name, const std::string &value, CSVError &error)
 Materialize the visible schema after validating the requested insertion.
 
bool try_insert_column (size_t index, const std::string &name, CSVError &error)
 
bool try_append_column (const std::string &name, CSVError &error)
 
bool try_append_column (const std::string &name, const std::string &value, CSVError &error)
 
DataFrame try_selected_rows (const std::vector< std::uint8_t > &mask, CSVError &error) const
 Selection preserves visible edits and returns an empty frame on failure.
 
DataFrameColumn< KeyType > column_view (size_t col_index)
 Access a column view by position.
 
DataFrameColumn< KeyType > column_view (size_t col_index) const
 Access a column view by position.
 
DataFrameColumn< KeyType > column_view (const std::string &name)
 Access a column view by name.
 
DataFrameColumn< KeyType > column_view (const std::string &name) const
 Access a column view by name.
 
template<typename K = KeyType, csv::enable_if_t<!std::is_integral< K >::value, int > = 0>
DataFrameRow< KeyType > operator[] (size_t i)
 Access a row by position with bounds checking.
 
template<typename K = KeyType, csv::enable_if_t<!std::is_integral< K >::value, int > = 0>
DataFrameRow< KeyType > operator[] (size_t i) const
 Access a row by position with bounds checking (const version).
 
DataFrameRow< KeyType > at (size_t i)
 Access a row by position with bounds checking.
 
DataFrameRow< KeyType > at (size_t i) const
 Access a row by position with bounds checking (const version).
 
DataFrameRow< KeyType > operator[] (const KeyType &key)
 Access a row by its key.
 
DataFrameRow< KeyType > operator[] (const KeyType &key) const
 Access a row by its key (const version).
 
bool contains (const KeyType &key) const
 Check if a key exists in the DataFrame.
 
template<typename T = std::string>
std::vector< T > column (const std::string &name) const
 Extract all values from a column with type conversion.
 
row_type try_at (size_t index, CSVError &error)
 Checked positional row access.
 
row_type try_at (size_t index, CSVError &error) const
 
row_type try_find (const KeyType &key, CSVError &error)
 
row_type try_find (const KeyType &key, CSVError &error) const
 
bool try_contains (const KeyType &key, CSVError &error) const
 
column_type try_column_view (size_t index, CSVError &error)
 
column_type try_column_view (size_t index, CSVError &error) const
 
column_type try_column_view (const std::string &name, CSVError &error)
 
column_type try_column_view (const std::string &name, CSVError &error) const
 
template<typename T = std::string>
std::vector< T > try_column (const std::string &name, CSVError &error) const
 
template<typename State , typename Fn >
void column_parallel_apply (DataFrameExecutor &executor, std::vector< State > &states, Fn &&fn) const
 Apply a batch-oriented function to each column, potentially in parallel.
 
template<typename State , typename Fn >
bool try_column_parallel_apply (DataFrameExecutor &executor, std::vector< State > &states, Fn &&fn, CSVError &error) const
 
template<typename State , typename Fn >
void column_parallel_apply (DataFrameExecutor &executor, const std::vector< size_t > &column_indices, std::vector< State > &states, Fn &&fn) const
 Apply a batch-oriented function to a selected subset of columns, potentially in parallel.
 
template<typename State , typename Fn >
bool try_column_parallel_apply (DataFrameExecutor &executor, const std::vector< size_t > &column_indices, std::vector< State > &states, Fn &&fn, CSVError &error) const
 
template<typename Fn >
void column_parallel_apply (DataFrameExecutor &executor, Fn &&fn) const
 Apply a read-only batch function to each column, potentially in parallel.
 
template<typename Fn >
bool try_column_parallel_apply (DataFrameExecutor &executor, Fn &&fn, CSVError &error) const
 
template<typename Fn >
void column_parallel_apply (DataFrameExecutor &executor, const std::vector< size_t > &column_indices, Fn &&fn) const
 Apply a read-only batch function to a selected subset of columns, potentially in parallel.
 
template<typename Fn >
bool try_column_parallel_apply (DataFrameExecutor &executor, const std::vector< size_t > &column_indices, Fn &&fn, CSVError &error) const
 
template<typename GroupFunc , typename GroupKey = invoke_result_t<GroupFunc, DataFrameRow<KeyType>>, csv::enable_if_t< internals::is_hashable< GroupKey >::value &&internals::is_equality_comparable< GroupKey >::value, int > = 0>
std::unordered_map< GroupKey, std::vector< size_t > > group_by (GroupFunc group_func) const
 Group row positions using an arbitrary grouping function.
 
std::unordered_map< std::string, std::vector< size_t > > group_by (const std::string &name) const
 Group row positions by the value of a column.
 
std::unordered_map< std::string, std::vector< size_t > > try_group_by (const std::string &name, CSVError &error) const
 Group visible string values, reporting lookup or short-row errors.
 
iterator begin ()
 Get iterator to the first row.
 
iterator end ()
 Get iterator past the last row.
 
const_iterator begin () const
 Get const iterator to the first row.
 
const_iterator end () const
 Get const iterator past the last row.
 
const_iterator cbegin () const
 Get const iterator to the first row (explicit).
 
const_iterator cend () const
 Get const iterator past the last row (explicit).
 

Static Public Member Functions

static std::unique_ptr< DataFrame > try_create (CSVReader &reader, CSVError &error)
 Read a frame, returning no object on validation or input failure.
 
static std::unique_ptr< DataFrame > try_create (CSVReader &reader, const DataFrameOptions &options, CSVError &error)
 
static std::unique_ptr< DataFrame > try_create (csv::string_view filename, CSVError &error, const CSVFormat &format=CSVFormat::guess_csv())
 
static std::unique_ptr< DataFrame > try_create (csv::string_view filename, const DataFrameOptions &options, CSVError &error, const CSVFormat &format=CSVFormat::guess_csv())
 
template<typename KeyFunc , csv::enable_if_t< csv::is_invocable_returning< KeyFunc, KeyType, const CSVRow & >::value, int > = 0>
static std::unique_ptr< DataFrame > try_create (CSVReader &reader, KeyFunc key_func, CSVError &error, DuplicateKeyPolicy policy=DuplicateKeyPolicy::OVERWRITE)
 
template<typename KeyFunc , csv::enable_if_t< csv::is_invocable_returning< KeyFunc, KeyType, const CSVRow & >::value, int > = 0>
static std::unique_ptr< DataFrame > try_create (CSVReader &reader, KeyFunc key_func, const DataFrameOptions &options, CSVError &error)
 

Friends

class DataFrameRow< KeyType >
 
class DataFrameColumn< KeyType >
 

Detailed Description

template<typename KeyType = std::string>
class csv::DataFrame< KeyType >

Definition at line 31 of file data_frame.hpp.

Member Typedef Documentation

◆ column_type

template<typename KeyType = std::string>
using csv::DataFrame< KeyType >::column_type = DataFrameColumn<KeyType>

Definition at line 36 of file data_frame.hpp.

◆ const_iterator

template<typename KeyType = std::string>
using csv::DataFrame< KeyType >::const_iterator = internals::indexed_proxy_iterator<const DataFrame<KeyType>, DataFrameRow<KeyType>, const_row_accessor>

Row-wise const iterator over DataFrameRow entries.

Provides read-only access to rows with edit support.

Definition at line 54 of file data_frame.hpp.

◆ DuplicateKeyPolicy

template<typename KeyType = std::string>
using csv::DataFrame< KeyType >::DuplicateKeyPolicy = DataFrameOptions::DuplicateKeyPolicy

Definition at line 71 of file data_frame.hpp.

◆ iterator

template<typename KeyType = std::string>
using csv::DataFrame< KeyType >::iterator = internals::indexed_proxy_iterator<DataFrame<KeyType>, DataFrameRow<KeyType>, mutable_row_accessor>

Row-wise iterator over DataFrameRow entries.

Provides access to rows with edit support.

Definition at line 51 of file data_frame.hpp.

◆ row_type

template<typename KeyType = std::string>
using csv::DataFrame< KeyType >::row_type = DataFrameRow<KeyType>

Definition at line 35 of file data_frame.hpp.

Constructor & Destructor Documentation

◆ DataFrame() [1/8]

template<typename KeyType = std::string>
csv::DataFrame< KeyType >::DataFrame ( CSVReader &  reader)
inlineexplicit

Construct an unkeyed DataFrame from a CSV reader.

Rows are accessible by position only.

Definition at line 81 of file data_frame.hpp.

◆ DataFrame() [2/8]

template<typename KeyType = std::string>
csv::DataFrame< KeyType >::DataFrame ( csv::string_view  filename,
CSVFormat  format = CSVFormat::guess_csv() 
)
inlineexplicit

Construct an unkeyed DataFrame directly from a CSV file.

By default, the delimiter and header are detected as for CSVReader. Pass a CSVFormat to configure parsing explicitly.

Definition at line 93 of file data_frame.hpp.

◆ DataFrame() [3/8]

template<typename KeyType = std::string>
csv::DataFrame< KeyType >::DataFrame ( std::vector< CSVRow >  rows)
inlineexplicit

Construct an unkeyed DataFrame from an existing batch of rows.

Definition at line 105 of file data_frame.hpp.

◆ DataFrame() [4/8]

template<typename KeyType = std::string>
csv::DataFrame< KeyType >::DataFrame ( CSVReader &  reader,
const DataFrameOptions &  options 
)
inlineexplicit

Construct a keyed DataFrame from a CSV reader with options.

Exceptions
std::runtime_errorif key column is empty or not found

Definition at line 114 of file data_frame.hpp.

◆ DataFrame() [5/8]

template<typename KeyType = std::string>
csv::DataFrame< KeyType >::DataFrame ( csv::string_view  filename,
const DataFrameOptions &  options,
CSVFormat  format = CSVFormat::guess_csv() 
)
inline

Construct a keyed DataFrame directly from a CSV file.

Exceptions
std::runtime_errorif key column is empty or not found

Definition at line 126 of file data_frame.hpp.

◆ DataFrame() [6/8]

template<typename KeyType = std::string>
csv::DataFrame< KeyType >::DataFrame ( CSVReader &  reader,
const std::string &  _key_column,
DuplicateKeyPolicy  policy = DuplicateKeyPolicy::OVERWRITE,
bool  throw_on_missing_key = true 
)
inline

Construct a keyed DataFrame using a column name as the key.

Exceptions
std::runtime_errorif key column is empty or not found

Definition at line 143 of file data_frame.hpp.

◆ DataFrame() [7/8]

template<typename KeyType = std::string>
template<typename KeyFunc , csv::enable_if_t< csv::is_invocable_returning< KeyFunc, KeyType, const CSVRow & >::value, int > = 0>
csv::DataFrame< KeyType >::DataFrame ( CSVReader &  reader,
KeyFunc  key_func,
DuplicateKeyPolicy  policy = DuplicateKeyPolicy::OVERWRITE 
)
inline

Construct a keyed DataFrame using a custom key function.

Exceptions
std::runtime_errorif policy is THROW and duplicate keys are encountered

Definition at line 166 of file data_frame.hpp.

◆ DataFrame() [8/8]

template<typename KeyType = std::string>
template<typename KeyFunc , csv::enable_if_t< csv::is_invocable_returning< KeyFunc, KeyType, const CSVRow & >::value, int > = 0>
csv::DataFrame< KeyType >::DataFrame ( CSVReader &  reader,
KeyFunc  key_func,
const DataFrameOptions &  options 
)
inline

Construct a keyed DataFrame using a custom key function with options.

Definition at line 181 of file data_frame.hpp.

Member Function Documentation

◆ append_column() [1/2]

template<typename KeyType = std::string>
void csv::DataFrame< KeyType >::append_column ( const std::string &  name)
inline

Append a new column with empty values.

Definition at line 300 of file data_frame.hpp.

◆ append_column() [2/2]

template<typename KeyType = std::string>
void csv::DataFrame< KeyType >::append_column ( const std::string &  name,
const std::string &  default_value 
)
inline

Append a new column with a default value.

Definition at line 307 of file data_frame.hpp.

◆ at() [1/2]

template<typename KeyType = std::string>
DataFrameRow< KeyType > csv::DataFrame< KeyType >::at ( size_t  i)
inline

Access a row by position with bounds checking.

Exceptions
std::out_of_rangeif index is out of bounds

Definition at line 459 of file data_frame.hpp.

◆ at() [2/2]

template<typename KeyType = std::string>
DataFrameRow< KeyType > csv::DataFrame< KeyType >::at ( size_t  i) const
inline

Access a row by position with bounds checking (const version).

Definition at line 469 of file data_frame.hpp.

◆ begin() [1/2]

template<typename KeyType = std::string>
iterator csv::DataFrame< KeyType >::begin ( )
inline

Get iterator to the first row.

Definition at line 787 of file data_frame.hpp.

◆ begin() [2/2]

template<typename KeyType = std::string>
const_iterator csv::DataFrame< KeyType >::begin ( ) const
inline

Get const iterator to the first row.

Definition at line 793 of file data_frame.hpp.

◆ cbegin()

template<typename KeyType = std::string>
const_iterator csv::DataFrame< KeyType >::cbegin ( ) const
inline

Get const iterator to the first row (explicit).

Definition at line 799 of file data_frame.hpp.

◆ cend()

template<typename KeyType = std::string>
const_iterator csv::DataFrame< KeyType >::cend ( ) const
inline

Get const iterator past the last row (explicit).

Definition at line 802 of file data_frame.hpp.

◆ column()

template<typename KeyType = std::string>
template<typename T = std::string>
std::vector< T > csv::DataFrame< KeyType >::column ( const std::string &  name) const
inline

Extract all values from a column with type conversion.

Accounts for edited values in the overlay.

Template Parameters
TTarget type for conversion (default: std::string)
Exceptions
std::out_of_rangeif column is not found

Definition at line 526 of file data_frame.hpp.

◆ column_parallel_apply() [1/4]

template<typename KeyType = std::string>
template<typename Fn >
void csv::DataFrame< KeyType >::column_parallel_apply ( DataFrameExecutor &  executor,
const std::vector< size_t > &  column_indices,
Fn &&  fn 
) const
inline

Apply a read-only batch function to a selected subset of columns, potentially in parallel.

This overload is for callers who want to process only specific columns and prefer to manage any output storage externally.

Exceptions
std::out_of_rangeif any column index is invalid

Definition at line 707 of file data_frame.hpp.

◆ column_parallel_apply() [2/4]

template<typename KeyType = std::string>
template<typename State , typename Fn >
void csv::DataFrame< KeyType >::column_parallel_apply ( DataFrameExecutor &  executor,
const std::vector< size_t > &  column_indices,
std::vector< State > &  states,
Fn &&  fn 
) const
inline

Apply a batch-oriented function to a selected subset of columns, potentially in parallel.

The callback receives a lightweight column view plus a mutable per-selected-column state object from states.

Exceptions
std::invalid_argumentif states.size() != column_indices.size()
std::out_of_rangeif any column index is invalid

Definition at line 633 of file data_frame.hpp.

◆ column_parallel_apply() [3/4]

template<typename KeyType = std::string>
template<typename Fn >
void csv::DataFrame< KeyType >::column_parallel_apply ( DataFrameExecutor &  executor,
Fn &&  fn 
) const
inline

Apply a read-only batch function to each column, potentially in parallel.

This overload is for callers who do not need one explicit mutable state object per column and prefer to manage any output storage externally.

Definition at line 675 of file data_frame.hpp.

◆ column_parallel_apply() [4/4]

template<typename KeyType = std::string>
template<typename State , typename Fn >
void csv::DataFrame< KeyType >::column_parallel_apply ( DataFrameExecutor &  executor,
std::vector< State > &  states,
Fn &&  fn 
) const
inline

Apply a batch-oriented function to each column, potentially in parallel.

The callback receives a lightweight column view plus a mutable per-column state object from states.

Callbacks may safely perform read-only access through the provided column view and any explicit read-only references they already hold to this batch-scoped DataFrame. Sparse-overlay cell edits through DataFrameRow or DataFrameCell are synchronized at row granularity, but structural mutations such as erase() are not thread-safe.

Exceptions
std::invalid_argumentif states.size() != n_cols()

Definition at line 594 of file data_frame.hpp.

◆ column_view() [1/4]

template<typename KeyType = std::string>
DataFrameColumn< KeyType > csv::DataFrame< KeyType >::column_view ( const std::string &  name)
inline

Access a column view by name.

Definition at line 405 of file data_frame.hpp.

◆ column_view() [2/4]

template<typename KeyType = std::string>
DataFrameColumn< KeyType > csv::DataFrame< KeyType >::column_view ( const std::string &  name) const
inline

Access a column view by name.

Definition at line 415 of file data_frame.hpp.

◆ column_view() [3/4]

template<typename KeyType = std::string>
DataFrameColumn< KeyType > csv::DataFrame< KeyType >::column_view ( size_t  col_index)
inline

Access a column view by position.

Definition at line 385 of file data_frame.hpp.

◆ column_view() [4/4]

template<typename KeyType = std::string>
DataFrameColumn< KeyType > csv::DataFrame< KeyType >::column_view ( size_t  col_index) const
inline

Access a column view by position.

Definition at line 395 of file data_frame.hpp.

◆ columns()

template<typename KeyType = std::string>
const std::vector< std::string > & csv::DataFrame< KeyType >::columns ( ) const
inlinenoexcept

Get the column names in order.

Definition at line 266 of file data_frame.hpp.

◆ contains()

template<typename KeyType = std::string>
bool csv::DataFrame< KeyType >::contains ( const KeyType &  key) const
inline

Check if a key exists in the DataFrame.

Exceptions
std::runtime_errorif the DataFrame was not created with a key column

Definition at line 509 of file data_frame.hpp.

◆ empty()

template<typename KeyType = std::string>
bool csv::DataFrame< KeyType >::empty ( ) const
inlinenoexcept

Check if the DataFrame is empty (has no rows).

Definition at line 245 of file data_frame.hpp.

◆ end() [1/2]

template<typename KeyType = std::string>
iterator csv::DataFrame< KeyType >::end ( )
inline

Get iterator past the last row.

Definition at line 790 of file data_frame.hpp.

◆ end() [2/2]

template<typename KeyType = std::string>
const_iterator csv::DataFrame< KeyType >::end ( ) const
inline

Get const iterator past the last row.

Definition at line 796 of file data_frame.hpp.

◆ group_by() [1/2]

template<typename KeyType = std::string>
std::unordered_map< std::string, std::vector< size_t > > csv::DataFrame< KeyType >::group_by ( const std::string &  name) const
inline

Group row positions by the value of a column.

Exceptions
std::out_of_rangeif column is not found

Definition at line 765 of file data_frame.hpp.

◆ group_by() [2/2]

template<typename KeyType = std::string>
template<typename GroupFunc , typename GroupKey = invoke_result_t<GroupFunc, DataFrameRow<KeyType>>, csv::enable_if_t< internals::is_hashable< GroupKey >::value &&internals::is_equality_comparable< GroupKey >::value, int > = 0>
std::unordered_map< GroupKey, std::vector< size_t > > csv::DataFrame< KeyType >::group_by ( GroupFunc  group_func) const
inline

Group row positions using an arbitrary grouping function.

Template Parameters
GroupFuncCallable that takes a DataFrameRow and returns a hashable key

Definition at line 748 of file data_frame.hpp.

◆ has_column()

template<typename KeyType = std::string>
bool csv::DataFrame< KeyType >::has_column ( const std::string &  name) const
inline

Check if a column exists in the DataFrame.

Definition at line 256 of file data_frame.hpp.

◆ index_of()

template<typename KeyType = std::string>
int csv::DataFrame< KeyType >::index_of ( const std::string &  name) const
inline

Get the index of a column by name.

Definition at line 261 of file data_frame.hpp.

◆ insert_column() [1/2]

template<typename KeyType = std::string>
void csv::DataFrame< KeyType >::insert_column ( size_t  index,
const std::string &  name 
)
inline

Insert a new column with empty values.

Materializes visible rows into fresh row storage and invalidates outstanding proxies.

Definition at line 281 of file data_frame.hpp.

◆ insert_column() [2/2]

template<typename KeyType = std::string>
void csv::DataFrame< KeyType >::insert_column ( size_t  index,
const std::string &  name,
const std::string &  default_value 
)
inline

Insert a new column with a default value.

Materializes visible rows into fresh row storage and invalidates outstanding proxies. Established row keys remain unchanged even when key-column values have been edited.

Definition at line 291 of file data_frame.hpp.

◆ insert_row()

template<typename KeyType = std::string>
void csv::DataFrame< KeyType >::insert_row ( size_t  index,
const std::vector< std::string > &  row 
)
inline

Insert a new row at the specified index.

Structural mutation invalidates outstanding row and cell proxies.

Definition at line 270 of file data_frame.hpp.

◆ n_cols()

template<typename KeyType = std::string>
size_t csv::DataFrame< KeyType >::n_cols ( ) const
inlinenoexcept

Get the number of visible columns in the DataFrame.

Definition at line 253 of file data_frame.hpp.

◆ n_rows()

template<typename KeyType = std::string>
size_t csv::DataFrame< KeyType >::n_rows ( ) const
inlinenoexcept

Get the number of rows in the DataFrame.

Alias for size().

Definition at line 250 of file data_frame.hpp.

◆ operator[]() [1/4]

template<typename KeyType = std::string>
DataFrameRow< KeyType > csv::DataFrame< KeyType >::operator[] ( const KeyType &  key)
inline

Access a row by its key.

Stored keys identify rows independently of subsequent key-column cell edits.

Exceptions
std::runtime_errorif the DataFrame was not created with a key column
std::out_of_rangeif the key is not found

Definition at line 485 of file data_frame.hpp.

◆ operator[]() [2/4]

template<typename KeyType = std::string>
DataFrameRow< KeyType > csv::DataFrame< KeyType >::operator[] ( const KeyType &  key) const
inline

Access a row by its key (const version).

Definition at line 495 of file data_frame.hpp.

◆ operator[]() [3/4]

template<typename KeyType = std::string>
template<typename K = KeyType, csv::enable_if_t<!std::is_integral< K >::value, int > = 0>
DataFrameRow< KeyType > csv::DataFrame< KeyType >::operator[] ( size_t  i)
inline

Access a row by position with bounds checking.

Note
Disabled when KeyType is an integral type to prevent ambiguity with operator[](const KeyType&). Use at(size_t) for positional access on integer-keyed DataFrames.
Exceptions
std::out_of_rangeif index is out of bounds

Definition at line 435 of file data_frame.hpp.

◆ operator[]() [4/4]

template<typename KeyType = std::string>
template<typename K = KeyType, csv::enable_if_t<!std::is_integral< K >::value, int > = 0>
DataFrameRow< KeyType > csv::DataFrame< KeyType >::operator[] ( size_t  i) const
inline

Access a row by position with bounds checking (const version).

Disabled when KeyType is an integral type — use at(size_t) instead.

Definition at line 445 of file data_frame.hpp.

◆ selected_rows()

template<typename KeyType = std::string>
DataFrame csv::DataFrame< KeyType >::selected_rows ( const std::vector< std::uint8_t > &  include_rows) const
inline

Build an unkeyed DataFrame containing rows whose corresponding mask entry is true.

CSVRow copies share the underlying parsed row storage, so this is intended for filtered document views that should avoid reparsing or rematerializing fields. Existing cell edits are copied; subsequent edits to either frame are independent.

Definition at line 319 of file data_frame.hpp.

◆ size()

template<typename KeyType = std::string>
size_t csv::DataFrame< KeyType >::size ( ) const
inlinenoexcept

Get the number of rows in the DataFrame.

Definition at line 240 of file data_frame.hpp.

◆ try_append_column() [1/2]

template<typename KeyType = std::string>
bool csv::DataFrame< KeyType >::try_append_column ( const std::string &  name,
const std::string &  value,
CSVError &  error 
)
inline

Definition at line 372 of file data_frame.hpp.

◆ try_append_column() [2/2]

template<typename KeyType = std::string>
bool csv::DataFrame< KeyType >::try_append_column ( const std::string &  name,
CSVError &  error 
)
inline

Definition at line 369 of file data_frame.hpp.

◆ try_at() [1/2]

template<typename KeyType = std::string>
row_type csv::DataFrame< KeyType >::try_at ( size_t  index,
CSVError &  error 
)
inline

Checked positional row access.

Failed lookups return an unbound proxy.

Definition at line 535 of file data_frame.hpp.

◆ try_at() [2/2]

template<typename KeyType = std::string>
row_type csv::DataFrame< KeyType >::try_at ( size_t  index,
CSVError &  error 
) const
inline

Definition at line 539 of file data_frame.hpp.

◆ try_column()

template<typename KeyType = std::string>
template<typename T = std::string>
std::vector< T > csv::DataFrame< KeyType >::try_column ( const std::string &  name,
CSVError &  error 
) const
inline

Definition at line 574 of file data_frame.hpp.

◆ try_column_parallel_apply() [1/4]

template<typename KeyType = std::string>
template<typename Fn >
bool csv::DataFrame< KeyType >::try_column_parallel_apply ( DataFrameExecutor &  executor,
const std::vector< size_t > &  column_indices,
Fn &&  fn,
CSVError &  error 
) const
inline

Definition at line 719 of file data_frame.hpp.

◆ try_column_parallel_apply() [2/4]

template<typename KeyType = std::string>
template<typename State , typename Fn >
bool csv::DataFrame< KeyType >::try_column_parallel_apply ( DataFrameExecutor &  executor,
const std::vector< size_t > &  column_indices,
std::vector< State > &  states,
Fn &&  fn,
CSVError &  error 
) const
inline

Definition at line 646 of file data_frame.hpp.

◆ try_column_parallel_apply() [3/4]

template<typename KeyType = std::string>
template<typename Fn >
bool csv::DataFrame< KeyType >::try_column_parallel_apply ( DataFrameExecutor &  executor,
Fn &&  fn,
CSVError &  error 
) const
inline

Definition at line 686 of file data_frame.hpp.

◆ try_column_parallel_apply() [4/4]

template<typename KeyType = std::string>
template<typename State , typename Fn >
bool csv::DataFrame< KeyType >::try_column_parallel_apply ( DataFrameExecutor &  executor,
std::vector< State > &  states,
Fn &&  fn,
CSVError &  error 
) const
inline

Definition at line 606 of file data_frame.hpp.

◆ try_column_view() [1/4]

template<typename KeyType = std::string>
column_type csv::DataFrame< KeyType >::try_column_view ( const std::string &  name,
CSVError &  error 
)
inline

Definition at line 565 of file data_frame.hpp.

◆ try_column_view() [2/4]

template<typename KeyType = std::string>
column_type csv::DataFrame< KeyType >::try_column_view ( const std::string &  name,
CSVError &  error 
) const
inline

Definition at line 569 of file data_frame.hpp.

◆ try_column_view() [3/4]

template<typename KeyType = std::string>
column_type csv::DataFrame< KeyType >::try_column_view ( size_t  index,
CSVError &  error 
)
inline

Definition at line 557 of file data_frame.hpp.

◆ try_column_view() [4/4]

template<typename KeyType = std::string>
column_type csv::DataFrame< KeyType >::try_column_view ( size_t  index,
CSVError &  error 
) const
inline

Definition at line 561 of file data_frame.hpp.

◆ try_contains()

template<typename KeyType = std::string>
bool csv::DataFrame< KeyType >::try_contains ( const KeyType &  key,
CSVError &  error 
) const
inline

Definition at line 551 of file data_frame.hpp.

◆ try_create() [1/6]

template<typename KeyType = std::string>
static std::unique_ptr< DataFrame > csv::DataFrame< KeyType >::try_create ( csv::string_view  filename,
const DataFrameOptions &  options,
CSVError &  error,
const CSVFormat &  format = CSVFormat::guess_csv() 
)
inlinestatic

Definition at line 212 of file data_frame.hpp.

◆ try_create() [2/6]

template<typename KeyType = std::string>
static std::unique_ptr< DataFrame > csv::DataFrame< KeyType >::try_create ( csv::string_view  filename,
CSVError &  error,
const CSVFormat &  format = CSVFormat::guess_csv() 
)
inlinestatic

Definition at line 204 of file data_frame.hpp.

◆ try_create() [3/6]

template<typename KeyType = std::string>
static std::unique_ptr< DataFrame > csv::DataFrame< KeyType >::try_create ( CSVReader &  reader,
const DataFrameOptions &  options,
CSVError &  error 
)
inlinestatic

Definition at line 196 of file data_frame.hpp.

◆ try_create() [4/6]

template<typename KeyType = std::string>
static std::unique_ptr< DataFrame > csv::DataFrame< KeyType >::try_create ( CSVReader &  reader,
CSVError &  error 
)
inlinestatic

Read a frame, returning no object on validation or input failure.

Definition at line 190 of file data_frame.hpp.

◆ try_create() [5/6]

template<typename KeyType = std::string>
template<typename KeyFunc , csv::enable_if_t< csv::is_invocable_returning< KeyFunc, KeyType, const CSVRow & >::value, int > = 0>
static std::unique_ptr< DataFrame > csv::DataFrame< KeyType >::try_create ( CSVReader &  reader,
KeyFunc  key_func,
const DataFrameOptions &  options,
CSVError &  error 
)
inlinestatic

Definition at line 233 of file data_frame.hpp.

◆ try_create() [6/6]

template<typename KeyType = std::string>
template<typename KeyFunc , csv::enable_if_t< csv::is_invocable_returning< KeyFunc, KeyType, const CSVRow & >::value, int > = 0>
static std::unique_ptr< DataFrame > csv::DataFrame< KeyType >::try_create ( CSVReader &  reader,
KeyFunc  key_func,
CSVError &  error,
DuplicateKeyPolicy  policy = DuplicateKeyPolicy::OVERWRITE 
)
inlinestatic

Definition at line 222 of file data_frame.hpp.

◆ try_find() [1/2]

template<typename KeyType = std::string>
row_type csv::DataFrame< KeyType >::try_find ( const KeyType &  key,
CSVError &  error 
)
inline

Definition at line 543 of file data_frame.hpp.

◆ try_find() [2/2]

template<typename KeyType = std::string>
row_type csv::DataFrame< KeyType >::try_find ( const KeyType &  key,
CSVError &  error 
) const
inline

Definition at line 547 of file data_frame.hpp.

◆ try_group_by()

template<typename KeyType = std::string>
std::unordered_map< std::string, std::vector< size_t > > csv::DataFrame< KeyType >::try_group_by ( const std::string &  name,
CSVError &  error 
) const
inline

Group visible string values, reporting lookup or short-row errors.

Definition at line 774 of file data_frame.hpp.

◆ try_insert_column() [1/2]

template<typename KeyType = std::string>
bool csv::DataFrame< KeyType >::try_insert_column ( size_t  index,
const std::string &  name,
const std::string &  value,
CSVError &  error 
)
inline

Materialize the visible schema after validating the requested insertion.

Definition at line 357 of file data_frame.hpp.

◆ try_insert_column() [2/2]

template<typename KeyType = std::string>
bool csv::DataFrame< KeyType >::try_insert_column ( size_t  index,
const std::string &  name,
CSVError &  error 
)
inline

Definition at line 366 of file data_frame.hpp.

◆ try_insert_row()

template<typename KeyType = std::string>
bool csv::DataFrame< KeyType >::try_insert_row ( size_t  index,
const std::vector< std::string > &  row,
CSVError &  error 
)
inline

Insert a row; validation failures leave the frame unchanged.

Definition at line 328 of file data_frame.hpp.

◆ try_selected_rows()

template<typename KeyType = std::string>
DataFrame csv::DataFrame< KeyType >::try_selected_rows ( const std::vector< std::uint8_t > &  mask,
CSVError &  error 
) const
inline

Selection preserves visible edits and returns an empty frame on failure.

Definition at line 377 of file data_frame.hpp.

Friends And Related Symbol Documentation

◆ DataFrameColumn< KeyType >

template<typename KeyType = std::string>
friend class DataFrameColumn< KeyType >
friend

Definition at line 1107 of file data_frame.hpp.

◆ DataFrameRow< KeyType >

template<typename KeyType = std::string>
friend class DataFrameRow< KeyType >
friend

Definition at line 1107 of file data_frame.hpp.


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