Qore CsvUtil Module Reference
1.1
|
the CsvFileWriter class for easy and safe CSV file creation More...
Inherits CsvHelper.
Public Member Functions | |
constructor (string path, *hash opts) | |
creates the CsvFileWriter with the path of the file to read with an options More... | |
write (AbstractIterator iterator) | |
stream iterator into the file. More... | |
writeLine (list values) | |
write a line with list of values. Data are checked against column rules. More... | |
writeLine (hash values) | |
write a line with headers-values hash More... | |
Private Attributes | |
const | Options |
valid options for the object (a hash for quick lookups of valid keys) | |
the CsvFileWriter class for easy and safe CSV file creation
The CsvFileIterator class constructor takes an optional hash with possible keys given in the following table. Note that key names are case-sensitive, and data types are soft (conversions are made when possible).
CsvFileWriter Options
Option | Data Type | Description |
"encoding" | String | the character encoding for the file (and for tagging string data read); if the value of this key is not a string then it will be ignored |
"separator" | String | the string separating the fields in the file (default: "," ) |
"quote" | String | the field quote character (default: '"' ) |
"eol" | String | the end of line character(s) (default: auto-detect); if the value of this key is not a string then it will be ignored |
"headers" | List of strings | list of header / column names for the data iterated |
"verify-columns" | Boolean | if True (the default is False) then if a line is parsed with a different column count than other lines, a CSVFILEWRITER-DATA-ERROR exception is thrown |
"date-format" | String | the default mask for date values formatting |
creates the CsvFileWriter with the path of the file to read with an options
path | a filename (with path) |
opts | CsvFileWriter Constructor Option Hash Overview |
CSVFILEWRITER-ERROR | in the case of incorrect options |
CsvUtil::CsvFileWriter::write | ( | AbstractIterator | iterator | ) |
stream iterator into the file.
iterator | an iterator to stream data into file |
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 |
CsvUtil::CsvFileWriter::writeLine | ( | list | values | ) |
write a line with list of values. Data are checked against column rules.
values | a list with values |
CSVFILEWRITER-DATA-ERROR | when the data does not fit defined column constraints |
CsvUtil::CsvFileWriter::writeLine | ( | hash | values | ) |
write a line with headers-values hash
values | a hash with keys as column headers. |
CSVFILEWRITER-DATA-ERROR | when the data does not fit defined column constraints |