|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Lazy CSV reader for large files. More...
#include <parse-csv.H>
Classes | |
| class | Iterator |
Public Member Functions | |
| CsvReader (const std::string &filename, char delimiter=',') | |
| Construct reader from file path. | |
| CsvReader (std::istream &stream, char delimiter=',') | |
| Construct reader from stream. | |
| Array< std::string > | read_header () |
| Read and store the header row. | |
| bool | has_next () const |
| Check if more rows are available. | |
| Array< std::string > | next () |
| Read the next row as Array. | |
| CsvRow | next_row () |
| Read the next row with header access. | |
| size_t | rows_read () const |
| Get number of rows read so far. | |
| const Array< std::string > & | header () const |
| Get the header (if read). | |
| bool | has_header () const |
| Check if header was read. | |
| void | skip (size_t n) |
| Skip N rows. | |
| void | reset () |
| Reset to beginning (only works for file-based readers). | |
| Iterator | begin () |
| Iterator | end () |
Private Attributes | |
| std::ifstream | file_ |
| std::istream * | stream_ |
| bool | owns_stream_ |
| char | delimiter_ |
| Array< std::string > | header_ |
| bool | has_header_ |
| size_t | row_count_ |
Lazy CSV reader for large files.
CsvReader provides an iterator-based interface for reading CSV files row by row without loading the entire file into memory.
Definition at line 710 of file parse-csv.H.
Construct reader from file path.
| std::runtime_error | If file cannot be opened. |
Definition at line 723 of file parse-csv.H.
References file_, and Aleph::maps().
|
inlineexplicit |
Construct reader from stream.
Definition at line 732 of file parse-csv.H.
|
inline |
Definition at line 831 of file parse-csv.H.
|
inline |
Definition at line 832 of file parse-csv.H.
|
inline |
|
inline |
Check if more rows are available.
Definition at line 746 of file parse-csv.H.
References Aleph::maps(), and stream_.
Referenced by Aleph::CsvReader::Iterator::Iterator(), Aleph::CsvReader::Iterator::operator++(), and skip().
|
inline |
Read the next row as Array.
Definition at line 752 of file parse-csv.H.
References Aleph::csv_read_row(), delimiter_, row_count_, and stream_.
Referenced by Aleph::CsvReader::Iterator::Iterator(), Aleph::CsvReader::Iterator::operator++(), and skip().
|
inline |
Read the next row with header access.
Definition at line 759 of file parse-csv.H.
References Aleph::csv_read_row(), delimiter_, has_header_, header_, row_count_, and stream_.
|
inline |
Read and store the header row.
Definition at line 738 of file parse-csv.H.
References Aleph::csv_read_row(), delimiter_, has_header_, header_, and stream_.
Referenced by reset().
|
inline |
Reset to beginning (only works for file-based readers).
Definition at line 785 of file parse-csv.H.
References file_, has_header_, owns_stream_, read_header(), and row_count_.
|
inline |
Skip N rows.
Definition at line 778 of file parse-csv.H.
References has_next(), Aleph::maps(), and next().
|
private |
Definition at line 715 of file parse-csv.H.
Referenced by next(), next_row(), and read_header().
|
private |
Definition at line 712 of file parse-csv.H.
Referenced by CsvReader(), and reset().
|
private |
Definition at line 717 of file parse-csv.H.
Referenced by has_header(), next_row(), read_header(), and reset().
|
private |
Definition at line 716 of file parse-csv.H.
Referenced by header(), next_row(), and read_header().
|
private |
Definition at line 714 of file parse-csv.H.
Referenced by reset().
|
private |
Definition at line 718 of file parse-csv.H.
Referenced by next(), next_row(), reset(), and rows_read().
|
private |
Definition at line 713 of file parse-csv.H.
Referenced by has_next(), next(), next_row(), and read_header().