|
Vince's CSV Parser
|
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 > |
Definition at line 31 of file data_frame.hpp.
| using csv::DataFrame< KeyType >::column_type = DataFrameColumn<KeyType> |
Definition at line 36 of file data_frame.hpp.
| 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.
| using csv::DataFrame< KeyType >::DuplicateKeyPolicy = DataFrameOptions::DuplicateKeyPolicy |
Definition at line 71 of file data_frame.hpp.
| 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.
| using csv::DataFrame< KeyType >::row_type = DataFrameRow<KeyType> |
Definition at line 35 of file data_frame.hpp.
|
inlineexplicit |
Construct an unkeyed DataFrame from a CSV reader.
Rows are accessible by position only.
Definition at line 81 of file data_frame.hpp.
|
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.
|
inlineexplicit |
Construct an unkeyed DataFrame from an existing batch of rows.
Definition at line 105 of file data_frame.hpp.
|
inlineexplicit |
Construct a keyed DataFrame from a CSV reader with options.
| std::runtime_error | if key column is empty or not found |
Definition at line 114 of file data_frame.hpp.
|
inline |
Construct a keyed DataFrame directly from a CSV file.
| std::runtime_error | if key column is empty or not found |
Definition at line 126 of file data_frame.hpp.
|
inline |
Construct a keyed DataFrame using a column name as the key.
| std::runtime_error | if key column is empty or not found |
Definition at line 143 of file data_frame.hpp.
|
inline |
Construct a keyed DataFrame using a custom key function.
| std::runtime_error | if policy is THROW and duplicate keys are encountered |
Definition at line 166 of file data_frame.hpp.
|
inline |
Construct a keyed DataFrame using a custom key function with options.
Definition at line 181 of file data_frame.hpp.
|
inline |
Append a new column with empty values.
Definition at line 300 of file data_frame.hpp.
|
inline |
Append a new column with a default value.
Definition at line 307 of file data_frame.hpp.
|
inline |
Access a row by position with bounds checking.
| std::out_of_range | if index is out of bounds |
Definition at line 459 of file data_frame.hpp.
|
inline |
Access a row by position with bounds checking (const version).
Definition at line 469 of file data_frame.hpp.
|
inline |
Get iterator to the first row.
Definition at line 787 of file data_frame.hpp.
|
inline |
Get const iterator to the first row.
Definition at line 793 of file data_frame.hpp.
|
inline |
Get const iterator to the first row (explicit).
Definition at line 799 of file data_frame.hpp.
|
inline |
Get const iterator past the last row (explicit).
Definition at line 802 of file data_frame.hpp.
|
inline |
Extract all values from a column with type conversion.
Accounts for edited values in the overlay.
| T | Target type for conversion (default: std::string) |
| std::out_of_range | if column is not found |
Definition at line 526 of file data_frame.hpp.
|
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.
| std::out_of_range | if any column index is invalid |
Definition at line 707 of file data_frame.hpp.
|
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.
| std::invalid_argument | if states.size() != column_indices.size() |
| std::out_of_range | if any column index is invalid |
Definition at line 633 of file data_frame.hpp.
|
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.
|
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.
| std::invalid_argument | if states.size() != n_cols() |
Definition at line 594 of file data_frame.hpp.
|
inline |
Access a column view by name.
Definition at line 405 of file data_frame.hpp.
|
inline |
Access a column view by name.
Definition at line 415 of file data_frame.hpp.
|
inline |
Access a column view by position.
Definition at line 385 of file data_frame.hpp.
|
inline |
Access a column view by position.
Definition at line 395 of file data_frame.hpp.
|
inlinenoexcept |
Get the column names in order.
Definition at line 266 of file data_frame.hpp.
|
inline |
Check if a key exists in the DataFrame.
| std::runtime_error | if the DataFrame was not created with a key column |
Definition at line 509 of file data_frame.hpp.
|
inlinenoexcept |
Check if the DataFrame is empty (has no rows).
Definition at line 245 of file data_frame.hpp.
|
inline |
Get iterator past the last row.
Definition at line 790 of file data_frame.hpp.
|
inline |
Get const iterator past the last row.
Definition at line 796 of file data_frame.hpp.
|
inline |
Group row positions by the value of a column.
| std::out_of_range | if column is not found |
Definition at line 765 of file data_frame.hpp.
|
inline |
Group row positions using an arbitrary grouping function.
| GroupFunc | Callable that takes a DataFrameRow and returns a hashable key |
Definition at line 748 of file data_frame.hpp.
|
inline |
Check if a column exists in the DataFrame.
Definition at line 256 of file data_frame.hpp.
|
inline |
Get the index of a column by name.
Definition at line 261 of file data_frame.hpp.
|
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.
|
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.
|
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.
|
inlinenoexcept |
Get the number of visible columns in the DataFrame.
Definition at line 253 of file data_frame.hpp.
|
inlinenoexcept |
Get the number of rows in the DataFrame.
Alias for size().
Definition at line 250 of file data_frame.hpp.
|
inline |
Access a row by its key.
Stored keys identify rows independently of subsequent key-column cell edits.
| std::runtime_error | if the DataFrame was not created with a key column |
| std::out_of_range | if the key is not found |
Definition at line 485 of file data_frame.hpp.
|
inline |
Access a row by its key (const version).
Definition at line 495 of file data_frame.hpp.
|
inline |
Access a row by position with bounds checking.
| std::out_of_range | if index is out of bounds |
Definition at line 435 of file data_frame.hpp.
|
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.
|
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.
|
inlinenoexcept |
Get the number of rows in the DataFrame.
Definition at line 240 of file data_frame.hpp.
|
inline |
Definition at line 372 of file data_frame.hpp.
|
inline |
Definition at line 369 of file data_frame.hpp.
|
inline |
Checked positional row access.
Failed lookups return an unbound proxy.
Definition at line 535 of file data_frame.hpp.
|
inline |
Definition at line 539 of file data_frame.hpp.
|
inline |
Definition at line 574 of file data_frame.hpp.
|
inline |
Definition at line 719 of file data_frame.hpp.
|
inline |
Definition at line 646 of file data_frame.hpp.
|
inline |
Definition at line 686 of file data_frame.hpp.
|
inline |
Definition at line 606 of file data_frame.hpp.
|
inline |
Definition at line 565 of file data_frame.hpp.
|
inline |
Definition at line 569 of file data_frame.hpp.
|
inline |
Definition at line 557 of file data_frame.hpp.
|
inline |
Definition at line 561 of file data_frame.hpp.
|
inline |
Definition at line 551 of file data_frame.hpp.
|
inlinestatic |
Definition at line 212 of file data_frame.hpp.
|
inlinestatic |
Definition at line 204 of file data_frame.hpp.
|
inlinestatic |
Definition at line 196 of file data_frame.hpp.
|
inlinestatic |
Read a frame, returning no object on validation or input failure.
Definition at line 190 of file data_frame.hpp.
|
inlinestatic |
Definition at line 233 of file data_frame.hpp.
|
inlinestatic |
Definition at line 222 of file data_frame.hpp.
|
inline |
Definition at line 543 of file data_frame.hpp.
|
inline |
Definition at line 547 of file data_frame.hpp.
|
inline |
Group visible string values, reporting lookup or short-row errors.
Definition at line 774 of file data_frame.hpp.
|
inline |
Materialize the visible schema after validating the requested insertion.
Definition at line 357 of file data_frame.hpp.
|
inline |
Definition at line 366 of file data_frame.hpp.
|
inline |
Insert a row; validation failures leave the frame unchanged.
Definition at line 328 of file data_frame.hpp.
|
inline |
Selection preserves visible edits and returns an empty frame on failure.
Definition at line 377 of file data_frame.hpp.
|
friend |
Definition at line 1107 of file data_frame.hpp.
|
friend |
Definition at line 1107 of file data_frame.hpp.