Turi Create
4.0
|
#include <core/storage/sframe_data/csv_writer.hpp>
Public Types | |
enum | csv_quote_level { csv_quote_level::QUOTE_MINIMAL , csv_quote_level::QUOTE_NONNUMERIC, csv_quote_level::QUOTE_NONE } |
Public Member Functions | |
void | write_verbatim (std::ostream &out, const std::vector< std::string > &row) |
void | write (std::ostream &out, const std::vector< flexible_type > &row) |
void | csv_print (std::ostream &out, const flexible_type &val, bool allow_empty_output=true) |
Public Attributes | |
std::string | delimiter = "," |
char | escape_char = '\\' |
bool | use_escape_char = true |
bool | double_quote = true |
char | quote_char = '\"' |
std::string | line_terminator = "\n" |
bool | header = true |
csv_quote_level | quote_level = csv_quote_level::QUOTE_NONNUMERIC |
std::string | na_value = "" |
CSV Writer
Definition at line 24 of file csv_writer.hpp.
|
strong |
Definition at line 29 of file csv_writer.hpp.
void turi::csv_writer::csv_print | ( | std::ostream & | out, |
const flexible_type & | val, | ||
bool | allow_empty_output = true |
||
) |
Converts one value to a string.
out | The stream to write to |
val | The value of emit |
allow_empty_output | This parameter is a little tricky to interpret. If this flag is set to true (default), some inputs may result in completely empty outputs. (For instance empty string, or missing value where na_value is the empty string). This can cause issues in some situations. For instance, in a csv file with only a single columns, some parsers may skip empty lines. If this flag is set to false, the complete empty output will never be emitted and instead out << quote_char << quote_char will be generated. |
void turi::csv_writer::write | ( | std::ostream & | out, |
const std::vector< flexible_type > & | row | ||
) |
Writes an array of values as a row, making the appropriate formatting changes. Not safe to use in parallel.
void turi::csv_writer::write_verbatim | ( | std::ostream & | out, |
const std::vector< std::string > & | row | ||
) |
Writes an array of strings as a row, verbatim without escaping / modifications. (only inserting delimiter characters). Not safe to use in parallel.
std::string turi::csv_writer::delimiter = "," |
The delimiter character to use to separate fields (Default ',')
Definition at line 39 of file csv_writer.hpp.
bool turi::csv_writer::double_quote = true |
If set to true, pairs of quote characters in a quoted string are interpreted as a single quote (Default false). For instance, if set to true, the 2nd field of the 2nd line is read as "hello "world""
* user, message * 123, "hello ""world""" *
Definition at line 66 of file csv_writer.hpp.
char turi::csv_writer::escape_char = '\\' |
The character to use to identify the beginning of a C escape sequence (Defualt '\'). i.e. "\n" will be converted to the '
' character, "\\" will be converted to "\", etc. Note that only the single character escapes are converted. unicode (), octal (), hexadecimal () are not interpreted.
Definition at line 48 of file csv_writer.hpp.
bool turi::csv_writer::header = true |
Whether the header is written
Definition at line 81 of file csv_writer.hpp.
std::string turi::csv_writer::line_terminator = "\n" |
new line terminator. Defaults to "\n"
Definition at line 76 of file csv_writer.hpp.
std::string turi::csv_writer::na_value = "" |
String to emit for missing values
Definition at line 91 of file csv_writer.hpp.
char turi::csv_writer::quote_char = '\"' |
The quote character to use (Default '"')
Definition at line 71 of file csv_writer.hpp.
csv_quote_level turi::csv_writer::quote_level = csv_quote_level::QUOTE_NONNUMERIC |
The quoting level. Defaults to quoting everything except for numbers
Definition at line 86 of file csv_writer.hpp.
bool turi::csv_writer::use_escape_char = true |
If true, escape characters will not be used at all. Note that enabling this may result in non-parseable CSVs.
Definition at line 54 of file csv_writer.hpp.