HiPipe  0.7.0
C++17 data pipeline with Python bindings.
Classes | Functions
CSV parser.

Classes

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

Functions

dataframe hipipe::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 hipipe::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...
 
std::ostream & hipipe::write_csv_row (std::ostream &out, const std::vector< std::string > &row, char separator=',', char quote='"', char escape = '\\')
 Write a single csv row to an std::ostream. More...
 
std::ostream & hipipe::write_csv (std::ostream &out, const dataframe &df, char separator=',', char quote='"', char escape = '\\')
 Write a dataframe to an std::ostream. More...
 
void hipipe::write_csv (const std::experimental::filesystem::path &file, const dataframe &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 hipipe::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.

◆ read_csv() [2/2]

dataframe hipipe::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.

◆ write_csv() [1/2]

void hipipe::write_csv ( const std::experimental::filesystem::path &  file,
const dataframe 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.

◆ write_csv() [2/2]

std::ostream& hipipe::write_csv ( std::ostream &  out,
const dataframe 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.

◆ write_csv_row()

std::ostream& hipipe::write_csv_row ( std::ostream &  out,
const std::vector< std::string > &  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.