cxtream  0.5.1
C++17 data pipeline with Python bindings.
Classes | Functions
CSV parser.

Classes

class  cxtream::csv_istream_range
 Parse and iterate over CSV formatted rows from an istream. More...
 

Functions

dataframe cxtream::read_csv (std::istream &in, int drop=0, bool has_header=true, char separator=',', char quote='"', char escape = '\)
 Parse csv file from an std::istream. More...
 
dataframe cxtream::read_csv (const std::experimental::filesystem::path &file, int drop=0, bool header=true, char separator=',', char quote='"', char escape = '\)
 Same as read_csv() but read directly from a file. More...
 
template<typename Row >
std::ostream & cxtream::write_csv_row (std::ostream &out, Row &&row, char separator=',', char quote='"', char escape = '\)
 Write a single csv row to an std::ostream. More...
 
template<typename DataTable >
std::ostream & cxtream::write_csv (std::ostream &out, const dataframe< DataTable > &df, char separator=',', char quote='"', char escape = '\)
 Write a dataframe to an std::ostream. More...
 
template<typename DataTable >
void cxtream::write_csv (const std::experimental::filesystem::path &file, const dataframe< DataTable > &df, char separator=',', char quote='"', char escape = '\)
 Same as write_csv(std::ostream...), but write directly to a file. More...
 

Detailed Description

Function Documentation

◆ read_csv() [1/2]

dataframe cxtream::read_csv ( std::istream &  in,
int  drop = 0,
bool  has_header = true,
char  separator = ',',
char  quote = '"',
char  escape = '\\' 
)

Parse csv file from an std::istream.

Parsing has the same rules as for csv_istream_range.

Parameters
inThe input stream.
dropHow many lines should be ignored at the very beginning of the stream.
has_headerWhether a header row should be parsed (after drop).
separatorField separator.
quoteQuote character.
escapeCharacter used to escape a quote inside quotes.

Definition at line 193 of file csv.hpp.

◆ read_csv() [2/2]

dataframe cxtream::read_csv ( const std::experimental::filesystem::path &  file,
int  drop = 0,
bool  header = true,
char  separator = ',',
char  quote = '"',
char  escape = '\\' 
)

Same as read_csv() but read directly from a file.

Exceptions
std::ios_base::failureIf the specified file cannot be opened.

Definition at line 256 of file csv.hpp.

◆ write_csv() [1/2]

template<typename DataTable >
std::ostream& cxtream::write_csv ( std::ostream &  out,
const dataframe< DataTable > &  df,
char  separator = ',',
char  quote = '"',
char  escape = '\\' 
)

Write a dataframe to an std::ostream.

Fields containing a quote, a newline, or a separator are quoted automatically.

Exceptions
std::ios_base::failureif badbit is triggered.

Definition at line 324 of file csv.hpp.

◆ write_csv() [2/2]

template<typename DataTable >
void cxtream::write_csv ( const std::experimental::filesystem::path &  file,
const dataframe< DataTable > &  df,
char  separator = ',',
char  quote = '"',
char  escape = '\\' 
)

Same as write_csv(std::ostream...), but write directly to a file.

Exceptions
std::ios_base::failureIf the specified file cannot be opened.

Definition at line 341 of file csv.hpp.

◆ write_csv_row()

template<typename Row >
std::ostream& cxtream::write_csv_row ( std::ostream &  out,
Row &&  row,
char  separator = ',',
char  quote = '"',
char  escape = '\\' 
)

Write a single csv row to an std::ostream.

Fields containing a quote, a newline, or a separator are quoted automatically.

Exceptions
std::ios_base::failureif badbit is triggered.

Definition at line 287 of file csv.hpp.