|
Vince's CSV Parser
|
Stores information about how to parse a CSV file. More...
#include <csv_format.hpp>
Public Member Functions | |
| CSVFormat ()=default | |
| Settings for parsing a RFC 4180 CSV file. | |
| CSVFormat & | delimiter (char delim) |
| Sets the delimiter of the CSV file. | |
| CSVFormat & | delimiter (const std::vector< char > &delim) |
| Sets a list of potential delimiters. | |
| CSVFormat & | trim (const std::vector< char > &ws) |
| Sets the whitespace characters to be trimmed. | |
| CSVFormat & | quote (char quote) |
| Sets the quote character. | |
| CSVFormat & | column_names (const std::vector< std::string > &names) |
| Sets the column names. | |
| CSVFormat & | header_row (int row) |
| Sets the header row. | |
| CSVFormat & | no_header () |
| Tells the parser that this CSV has no header row. | |
| CSVFormat & | quote (bool use_quote) |
| Turn quoting on or off. | |
| CONSTEXPR_14 CSVFormat & | variable_columns (VariableColumnPolicy policy=VariableColumnPolicy::IGNORE_ROW) |
| Tells the parser how to handle columns of a different length than the others. | |
| CONSTEXPR_14 CSVFormat & | variable_columns (bool policy) |
| Tells the parser how to handle columns of a different length than the others. | |
| CSVFormat & | chunk_size (size_t size) |
| Sets the chunk size used when reading the CSV. | |
| bool | guess_delim () |
Static Public Member Functions | |
| static CSVFormat | guess_csv () |
| CSVFormat for guessing the delimiter. | |
Public Attributes | |
| friend | CSVReader |
Stores information about how to parse a CSV file.
Can be used to construct a csv::CSVReader.
Definition at line 36 of file csv_format.hpp.
| CSVFormat & csv::CSVFormat::chunk_size | ( | size_t | size | ) |
Sets the chunk size used when reading the CSV.
| [in] | size | Chunk size in bytes (minimum: 10MB = ITERATION_CHUNK_SIZE) |
| std::invalid_argument | if size < ITERATION_CHUNK_SIZE |
Use this when constructing a CSVReader from a filename and individual rows may exceed the default 10MB chunk size. The value is passed to CSVReader at construction time, before any data is read.
Definition at line 50 of file csv_format.cpp.
| CSVFormat & csv::CSVFormat::column_names | ( | const std::vector< std::string > & | names | ) |
Sets the column names.
Definition at line 36 of file csv_format.cpp.
| CSVFormat & csv::CSVFormat::delimiter | ( | char | delim | ) |
Sets the delimiter of the CSV file.
| `std::runtime_error` | thrown if trim, quote, or possible delimiting characters overlap |
Definition at line 11 of file csv_format.cpp.
| CSVFormat & csv::CSVFormat::delimiter | ( | const std::vector< char > & | delim | ) |
Sets a list of potential delimiters.
| `std::runtime_error` | thrown if trim, quote, or possible delimiting characters overlap |
| [in] | delim | An array of possible delimiters to try parsing the CSV with |
Definition at line 17 of file csv_format.cpp.
|
inlinestatic |
CSVFormat for guessing the delimiter.
Definition at line 138 of file csv_format.hpp.
|
inline |
Definition at line 147 of file csv_format.hpp.
| CSVFormat & csv::CSVFormat::header_row | ( | int | row | ) |
Sets the header row.
Definition at line 42 of file csv_format.cpp.
|
inline |
Tells the parser that this CSV has no header row.
header_row(-1) Definition at line 84 of file csv_format.hpp.
|
inline |
Turn quoting on or off.
Definition at line 90 of file csv_format.hpp.
| CSVFormat & csv::CSVFormat::quote | ( | char | quote | ) |
Sets the quote character.
| `std::runtime_error` | thrown if trim, quote, or possible delimiting characters overlap |
Definition at line 23 of file csv_format.cpp.
| CSVFormat & csv::CSVFormat::trim | ( | const std::vector< char > & | ws | ) |
Sets the whitespace characters to be trimmed.
| `std::runtime_error` | thrown if trim, quote, or possible delimiting characters overlap |
| [in] | ws | An array of whitespace characters that should be trimmed |
Definition at line 30 of file csv_format.cpp.
|
inline |
Tells the parser how to handle columns of a different length than the others.
Definition at line 102 of file csv_format.hpp.
|
inline |
Tells the parser how to handle columns of a different length than the others.
Definition at line 96 of file csv_format.hpp.
| friend csv::CSVFormat::CSVReader |
Definition at line 151 of file csv_format.hpp.