|
Vince's CSV Parser
|
The all encompassing namespace. More...
Namespaces | |
| internals | |
| Stuff that is generally not of interest to end-users. | |
Classes | |
| struct | CSVGuessResult |
| Stores the inferred format of a CSV file. More... | |
| class | CSVFormat |
| Stores information about how to parse a CSV file. More... | |
| class | CSVReader |
| Main class for parsing CSVs from files and in-memory sources. More... | |
| class | CSVField |
| Data type representing individual CSV values. More... | |
| class | CSVRow |
| Data structure for representing CSV rows. More... | |
| class | CSVStat |
| Class for calculating statistics from CSV files and in-memory sources. More... | |
| struct | CSVFileInfo |
| Returned by get_file_info() More... | |
| class | DelimWriter |
| Class for writing delimiter separated values files. More... | |
Typedefs | |
| using | RowCollection = internals::ThreadSafeDeque< CSVRow > |
| Standard type for storing collection of rows. | |
| using | string_view = nonstd::string_view |
| The string_view class used by this library. | |
| template<bool B, class T = void> | |
| using | enable_if_t = typename std::enable_if< B, T >::type |
Enumerations | |
| enum class | VariableColumnPolicy { THROW = -1 , IGNORE_ROW = 0 , KEEP = 1 } |
| Determines how to handle rows that are shorter or longer than the majority. | |
| enum class | DataType { UNKNOWN = -1 , CSV_NULL , CSV_STRING , CSV_INT8 , CSV_INT16 , CSV_INT32 , CSV_INT64 , CSV_BIGINT , CSV_DOUBLE } |
| Enumerates the different CSV field types that are recognized by this library. More... | |
Functions | |
| std::vector< std::string > | get_col_names (csv::string_view filename, CSVFormat format) |
| Return a CSV's column names. More... | |
| CSVGuessResult | guess_format (csv::string_view filename, const std::vector< char > &delims) |
| Guess the delimiter used by a delimiter-separated values file. | |
| CSVRow::operator std::vector< std::string > () const | |
| HEDLEY_NON_NULL (2) CSVRow | |
| template<> | |
| std::string | CSVField::get< std::string > () |
| Retrieve this field's original string. | |
| template<> | |
| CONSTEXPR_14 csv::string_view | CSVField::get< csv::string_view > () |
| Retrieve a view over this field's string. More... | |
Utility Functions | |
| std::unordered_map< std::string, DataType > | csv_data_types (const std::string &filename) |
| Useful for uploading CSV files to SQL databases. More... | |
| int | get_col_pos (csv::string_view filename, csv::string_view col_name, const CSVFormat &format) |
| Find the position of a column in a CSV file or CSV_NOT_FOUND otherwise. More... | |
| CSVFileInfo | get_file_info (const std::string &filename) |
| Get basic information about a CSV file. More... | |
Shorthand Parsing Functions | |
Convienience functions for parsing small strings | |
| CSVReader | parse (csv::string_view in, CSVFormat format) |
| Shorthand function for parsing an in-memory CSV string. More... | |
| CSVReader | parse_no_header (csv::string_view in) |
| Parses a CSV string with no headers. More... | |
| CSVReader | operator""_csv (const char *in, size_t n) |
| Parse a RFC 4180 CSV string, returning a collection of CSVRow objects. More... | |
| CSVReader | operator""_csv_no_header (const char *in, size_t n) |
| A shorthand for csv::parse_no_header() | |
Variables | |
| constexpr int | CSV_NOT_FOUND = -1 |
| Integer indicating a requested column wasn't found. | |
CSV Writing | |
| template<class OutputStream , bool Flush = true> | |
| using | CSVWriter = DelimWriter< OutputStream, ',', '"', Flush> |
| An alias for csv::DelimWriter for writing standard CSV files. More... | |
| template<class OutputStream , bool Flush = true> | |
| using | TSVWriter = DelimWriter< OutputStream, '\t', '"', Flush> |
| Class for writing tab-separated values files. More... | |
| template<class OutputStream > | |
| CSVWriter< OutputStream > | make_csv_writer (OutputStream &out, bool quote_minimal=true) |
| Return a csv::CSVWriter over the output stream. | |
| template<class OutputStream > | |
| CSVWriter< OutputStream, false > | make_csv_writer_buffered (OutputStream &out, bool quote_minimal=true) |
| Return a buffered csv::CSVWriter over the output stream (does not auto flush) | |
| template<class OutputStream > | |
| TSVWriter< OutputStream > | make_tsv_writer (OutputStream &out, bool quote_minimal=true) |
| Return a csv::TSVWriter over the output stream. | |
| template<class OutputStream > | |
| TSVWriter< OutputStream, false > | make_tsv_writer_buffered (OutputStream &out, bool quote_minimal=true) |
| Return a buffered csv::TSVWriter over the output stream (does not auto flush) | |
The all encompassing namespace.
| using csv::CSVWriter = typedef DelimWriter<OutputStream, ',', '"', Flush> |
An alias for csv::DelimWriter for writing standard CSV files.
csv::make_csv_writer() to in instatiate this class over an actual output stream. Definition at line 375 of file csv_writer.hpp.
| using csv::TSVWriter = typedef DelimWriter<OutputStream, '\t', '"', Flush> |
Class for writing tab-separated values files.
csv::make_tsv_writer() to in instatiate this class over an actual output stream. Definition at line 386 of file csv_writer.hpp.
|
strong |
Enumerates the different CSV field types that are recognized by this library.
Definition at line 20 of file data_type.hpp.
| std::unordered_map< std::string, DataType > csv::csv_data_types | ( | const std::string & | filename | ) |
Useful for uploading CSV files to SQL databases.
Return a data type for each column such that every value in a column can be converted to the corresponding data type without data loss.
| [in] | filename | The CSV file |
Definition at line 240 of file csv_stat.cpp.
| CONSTEXPR_14 csv::string_view csv::CSVField::get< csv::string_view > | ( | ) |
Retrieve a view over this field's string.
Definition at line 425 of file csv_row.hpp.
| std::vector< std::string > csv::get_col_names | ( | csv::string_view | filename, |
| CSVFormat | format | ||
| ) |
Return a CSV's column names.
| [in] | filename | Path to CSV file |
| [in] | format | Format of the CSV file |
Guess delimiter and header row
Definition at line 125 of file csv_reader.cpp.
| int csv::get_col_pos | ( | csv::string_view | filename, |
| csv::string_view | col_name, | ||
| const CSVFormat & | format | ||
| ) |
Find the position of a column in a CSV file or CSV_NOT_FOUND otherwise.
| [in] | filename | Path to CSV file |
| [in] | col_name | Column whose position we should resolve |
| [in] | format | Format of the CSV file |
Definition at line 53 of file csv_utility.cpp.
| CSVFileInfo csv::get_file_info | ( | const std::string & | filename | ) |
Get basic information about a CSV file.
Definition at line 64 of file csv_utility.cpp.
| CSVReader csv::operator""_csv | ( | const char * | in, |
| size_t | n | ||
| ) |
Parse a RFC 4180 CSV string, returning a collection of CSVRow objects.
Definition at line 37 of file csv_utility.cpp.
| CSVReader csv::parse | ( | csv::string_view | in, |
| CSVFormat | format | ||
| ) |
Shorthand function for parsing an in-memory CSV string.
Definition at line 14 of file csv_utility.cpp.
| CSVReader csv::parse_no_header | ( | csv::string_view | in | ) |
Parses a CSV string with no headers.
Definition at line 23 of file csv_utility.cpp.