Qore CsvUtil Module Reference
1.7
|
The CsvStringWriter class for in-memory string CSV creation. More...
Public Member Methods | |
constructor (*hash opts) | |
creates the CsvStringWriter single-type mode with content in the memory More... | |
constructor (hash spec, hash opts) | |
creates the CsvStringWriter single-type mode with content in the memory More... | |
string | getContent () |
Get the current in-memory content as a string. | |
string | write (Qore::AbstractIterator iterator) |
Stream iterator and return a CSV-formatted output string. More... | |
string | write (list l) |
Stream the contents of the list and return CSV-formatted output as a string. More... | |
Public Member Methods inherited from CsvUtil::AbstractCsvWriter | |
constructor (string n_errname, *hash< auto > n_opts) | |
Creates the AbstractCsvWriter in single-type mode. More... | |
constructor (string n_errname, hash< auto > spec, hash< auto > n_opts) | |
Creates the AbstractCsvWriter in single-type mode. More... | |
*hash< string, AbstractDataField > | getRecordType () |
Returns the description of the record type, if any. | |
write (Qore::AbstractIterator iterator) | |
Stream an iterator into the output. More... | |
write (Qore::SQL::SQLStatement iterator) | |
Stream an iterator into the output. More... | |
write (list< auto > l) | |
Stream the contents of the list into the output. More... | |
writeLine (list< auto > values) | |
Write a line with a list of values; data are checked against column rules. More... | |
writeLine (hash< auto > values) | |
Write a line with headers-values hash. More... | |
writeLine (string type, list< auto > values) | |
Write a line with headers-values list. More... | |
writeLine (string type, hash< auto > values) | |
Write a line for a specific record from a hash to the output. More... | |
Additional Inherited Members | |
Private Member Methods inherited from CsvUtil::AbstractCsvWriter | |
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. | |
Private Attributes inherited from CsvUtil::AbstractCsvWriter | |
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.
CsvUtil::CsvStringWriter::constructor | ( | *hash | opts | ) |
creates the CsvStringWriter single-type mode with content in the memory
opts | AbstractCsvWriter Constructor Option Hash Overview |
CSVSTRINGITER-ERROR | in the case of incorrect options |
creates the CsvStringWriter single-type mode with content in the memory
spec | a hash of field and type definitions; see Option Field Hash for more information |
opts | AbstractCsvWriter Constructor Option Hash Overview |
CSVSTRINGITER-ERROR | in the case of incorrect options |
string CsvUtil::CsvStringWriter::write | ( | Qore::AbstractIterator | iterator | ) |
Stream iterator and return a CSV-formatted output string.
iterator | an iterator to stream data |
The iterator has to contain List or Hash as a return value of getValue()
method.
CSVFILEWRITER-DATA-ERROR | when the data does not fit defined column constraints or when getValue does not return list or hash |
Stream the contents of the list and return CSV-formatted output as a string.
l | a list of input data to format as CSV output |
The list has to contain List or Hash elements that can be formatted according to the CSV definition
CSVFILEWRITER-DATA-ERROR | when the data does not fit defined column constraints or when the list elements have the wrong type or values |