The CsvStringWriter class for in-memory string CSV creation.
More...
#include <CsvStringWriter.qc.dox.h>
|
string | prepareRawLine (list< auto > values) |
| Prepare a string (line with EOF) with formatting and escaping. More...
|
|
| processCommonOptions (*hash< auto > n_opts, int C_OPTx) |
| Process options and set internal variables.
|
|
| processSpec () |
| Process specification and set internal variable for mapping.
|
|
| writeHeaders () |
| Write csv headers.
|
|
abstract | writeRawLine (list< auto > values) |
| This method must be overridden in child classes to provide the output implementation.
|
|
string | baseTemplate |
| base template for value format
|
|
int | block = 1000 |
| block size for bulk DML
|
|
bool | checkElementCounts = False |
| verify the column count for every row; if a row does not match, then throw a CSVFILEITERATOR-DATA-ERROR exception
|
|
string | encoding |
| output file character encoding
|
|
string | eol = EOL_UNIX |
| end of line sequence
|
|
*code | info_log |
| a closure/call reference for informational logging when using write(SQLStatement)
|
|
int | lineNo = 0 |
| the latest line number
|
|
hash | m_out_by_idx |
| mapping output field by index
|
|
hash | m_out_by_name |
| mapping output field by name
|
|
string | m_quoteEscapeChar = "\\" |
| quote escape character
|
|
bool | optimal_quotes = True |
| stores the optimal quotes option
|
|
const | Options |
| valid options for the object (a hash for quick lookups of valid keys)
|
|
string | quote = "\"" |
| field content delimiter
|
|
string | separator = "," |
| field separator
|
|
bool | write_headers = True |
| this flag determines if any stored headers are output
|
|
The CsvStringWriter class for in-memory string CSV creation.
- See also
- CsvWriter for a stream-based class providing the same functionality as this class in a more generic way
◆ constructor() [1/2]
CsvUtil::CsvStringWriter::constructor |
( |
*hash |
opts | ) |
|
creates the CsvStringWriter single-type mode with content in the memory
- Parameters
-
- Exceptions
-
CSVSTRINGITER-ERROR | in the case of incorrect options |
◆ constructor() [2/2]
CsvUtil::CsvStringWriter::constructor |
( |
hash |
spec, |
|
|
hash |
opts |
|
) |
| |
creates the CsvStringWriter single-type mode with content in the memory
- Parameters
-
- Exceptions
-
CSVSTRINGITER-ERROR | in the case of incorrect options |
◆ write() [1/2]
string CsvUtil::CsvStringWriter::write |
( |
list |
l | ) |
|
Stream the contents of the list and return CSV-formatted output as a string.
- Parameters
-
l | a list of input data to format as CSV output |
- Returns
- the CSV-formatted output string corresponding to the input data
The list has to contain List or Hash elements that can be formatted according to the CSV definition
- Exceptions
-
CSVFILEWRITER-DATA-ERROR | when the data does not fit defined column constraints or when the list elements have the wrong type or values |
◆ write() [2/2]
Stream iterator and return a CSV-formatted output string.
- Parameters
-
iterator | an iterator to stream data |
- Returns
- the CSV-formatted output string corresponding to the input data
The iterator has to contain List or Hash as a return value of getValue()
method.
- Exceptions
-
CSVFILEWRITER-DATA-ERROR | when the data does not fit defined column constraints or when getValue does not return list or hash |