326 const FieldAttrs = (
"type",
"format",
"timezone",
"code",
"header");
335 string number_format;
344 bool headerReorder =
True;
349 constructor (
string n_errname);
362 checkType(
string fld_errs,
string key,
string value);
369 hash getSpec(*
hash fields,
string fld_errs,
int C_OPTx);
671 "compat_force_empty_string": C_OPT1|C_OPT2,
672 "date_format": C_OPT1|C_OPT2,
673 "date-format": C_OPT1|C_OPT2,
674 "encoding": C_OPT1|C_OPT2,
675 "eol": C_OPT1|C_OPT2,
676 "extended_record": C_OPT2,
678 "header-lines": C_OPT1|C_OPT2,
679 "header_lines": C_OPT1|C_OPT2,
680 "header-names": C_OPT1|C_OPT2,
681 "header_names": C_OPT1|C_OPT2,
682 "header_reorder": C_OPT1|C_OPT2,
684 "ignore-empty": C_OPT1|C_OPT2,
685 "ignore_empty": C_OPT1|C_OPT2,
686 "ignore-whitespace": C_OPT1|C_OPT2,
687 "ignore_whitespace": C_OPT1|C_OPT2,
688 "number_format": C_OPT1|C_OPT2,
689 "quote": C_OPT1|C_OPT2,
690 "separator": C_OPT1|C_OPT2,
691 "timezone": C_OPT1|C_OPT2,
692 "tolwr": C_OPT1|C_OPT2,
693 "verify-columns": C_OPT1|C_OPT2,
694 "verify_columns": C_OPT1|C_OPT2,
698 string separator =
",";
704 softint headerLines = 0;
707 bool headerNames =
False;
710 bool ignoreEmptyLines =
True;
713 bool ignoreWhitespace =
True;
719 bool checkElementCounts =
False;
722 bool extendedRecord =
False;
725 bool compat_force_empty_string =
False;
734 hash m_resolve_by_rule;
737 hash m_resolve_by_count;
740 hash m_resolve_by_idx;
743 bool fakeHeaderNames;
746 AbstractLineIterator lineIterator;
953 auto handleType(
hash fh, *
string val);
1046 auto memberGate(
string name);
1097 hash<Qore::StatInfo>
hstat();
1134 auto memberGate(
string name);
1255 "block": C_OPT1|C_OPT2,
1257 "date_format": C_OPT1|C_OPT2,
1258 "date-format": C_OPT1|C_OPT2,
1259 "encoding": C_OPT1|C_OPT2,
1260 "eol": C_OPT1|C_OPT2,
1263 "header_reorder": C_OPT1,
1264 "info_log": C_OPT1|C_OPT2,
1265 "number_format": C_OPT1|C_OPT2,
1266 "optimal_quotes": C_OPT1|C_OPT2,
1267 "optimal-quotes": C_OPT1|C_OPT2,
1268 "quote": C_OPT1|C_OPT2,
1269 "quote_escape": C_OPT1|C_OPT2,
1270 "separator": C_OPT1|C_OPT2,
1271 "verify_columns": C_OPT1|C_OPT2,
1272 "verify-columns": C_OPT1|C_OPT2,
1273 "write_headers": C_OPT1|C_OPT2,
1274 "write-headers": C_OPT1|C_OPT2,
1455 string prepareRawLineIntern(
list values);
1541 openFile(
string path);
bool write_headers
this flag determines if any stored headers are output
Definition: CsvUtil.qm.dox.h:1305
constructor(string data, *hash opts)
Creates the CsvDataIterator with the input data and optionally an option hash.
hash m_out_by_name
mapping output field by name
Definition: CsvUtil.qm.dox.h:1314
constructor(*hash opts)
creates the CsvStringWriter single-type mode with content in the memory
int index()
Returns the row index being iterated, which does not necessarily correspond to the line number when t...
string write(Qore::AbstractIterator iterator)
Stream iterator and return a CSV-formatted output string.
hash parseLine()
Parses a line in the file and returns a processed list of the fields.
the AbstractCsvIterator class is an abstract base class that allows abstract CSV data to be iterated ...
Definition: CsvUtil.qm.dox.h:665
processCommonOptions(*hash n_opts, int C_OPTx)
Process options and set internal variables.
list getLineAndSplit()
Read line split by separator/quote into list.
writeHeaders()
Write csv headers.
Qore::File file
the file to write
Definition: CsvUtil.qm.dox.h:1510
const Options
valid options for the object (a hash for quick lookups of valid keys)
Definition: CsvUtil.qm.dox.h:670
hash m_out_by_idx
mapping output field by index
Definition: CsvUtil.qm.dox.h:1317
string getFileName()
Returns the file path/name used to open the file.
string getQuote()
Returns the current quote string.
bool checkElementCounts
verify the column count for every row; if a row does not match, then throw a CSVFILEITERATOR-DATA-ERR...
Definition: CsvUtil.qm.dox.h:1293
constructor(string path, *hash opts)
Creates the CsvFileIterator in single-type mode with the path of the file to read and an option hash...
string m_quoteEscapeChar
quote escape character
Definition: CsvUtil.qm.dox.h:1287
*code info_log
a closure/call reference for informational logging when using write(SQLStatement) ...
Definition: CsvUtil.qm.dox.h:1311
const Options
valid options for the object (a hash for quick lookups of valid keys)
Definition: CsvUtil.qm.dox.h:1254
write(Qore::AbstractIterator iterator)
Stream an iterator into the output.
The CsvFileIterator class allows CSV files to be iterated on a record basis.
Definition: CsvUtil.qm.dox.h:1058
string getContent()
Get the current in-memory content as a string.
string eol
end of line sequence
Definition: CsvUtil.qm.dox.h:1290
string getSeparator()
Returns the current separator string.
The CsvStringWriter class for in-memory string CSV creation.
Definition: CsvUtil.qm.dox.h:1557
string separator
field separator
Definition: CsvUtil.qm.dox.h:1281
string quote
field content delimiter
Definition: CsvUtil.qm.dox.h:1284
csvutil_set_global_compat_force_empty_string(softbool val)
sets the global_compat_force_empty_string variable to force "*string" fields with no value to ret...
list stat()
Returns a stat list of the underlying file.
*string identifyTypeImpl(list rec)
Identify a input record, given the raw line string. This method performs a lookup to a precalculated ...
processSpec()
Process specification and set internal variable for mapping.
The AbstractCsvWriter class provides a parent for all CSV writers.
Definition: CsvUtil.qm.dox.h:1249
string baseTemplate
base template for value format
Definition: CsvUtil.qm.dox.h:1302
const EOL_MACINTOSH
Old (pre-OSX) Macintosh end of line character sequence.
Definition: CsvUtil.qm.dox.h:404
const CSV_TYPE_UNKNOWN
Record type when non matching any type.
Definition: CsvUtil.qm.dox.h:410
const EOL_UNIX
Unix end of line character sequence (for new OS X too)
Definition: CsvUtil.qm.dox.h:400
StreamWriter output
the output stream for the CSV data
Definition: CsvUtil.qm.dox.h:1467
The CsvWriter class for safe CSV data creation.
Definition: CsvUtil.qm.dox.h:1462
*list getHeaders()
Returns the current record headers or NOTHING if no headers have been detected or saved yet...
constructor(string n_errname, *hash n_opts)
Creates the AbstractCsvWriter in single-type mode.
The CsvIterator class allows CSV sources to be iterated on a record basis. The source of the input da...
Definition: CsvUtil.qm.dox.h:1003
int lineNo
the latest line number
Definition: CsvUtil.qm.dox.h:1296
writeLine(list values)
Write a line with a list of values; data are checked against column rules.
hash getValue()
Returns the current record as a hash.
const EOL_WIN
MS DOS/Windows end of line character sequence.
Definition: CsvUtil.qm.dox.h:402
string prepareRawLine(list values)
Prepare a string (line with EOF) with formatting and escaping.
The CsvDataIterator class allows arbitrary CSV string data to be iterated on a record basis...
Definition: CsvUtil.qm.dox.h:1113
string m_file_path
the path of the file being iterated
Definition: CsvUtil.qm.dox.h:1063
writeRawLine(list values)
This method must be overridden in child classes to provide the output implementation.
constructor(string path, *hash opts)
creates the CsvFileWriter in single-type mode with the path of the file to create and an optional opt...
int block
block size for bulk DML
Definition: CsvUtil.qm.dox.h:1299
string identifyType(list rec)
Identify a fixed-length line type using identifyTypeImpl(); may be overridden if necessary.
bool optimal_quotes
stores the optimal quotes option
Definition: CsvUtil.qm.dox.h:1308
string encoding
output file character encoding
Definition: CsvUtil.qm.dox.h:1278
auto memberGate(string name)
Returns the given column value for the current row.
the CsvUtil namespace contains all the objects in the CsvUtil module
Definition: CsvUtil.qm.dox.h:398
bool global_compat_force_empty_string
global option to force "*string" fields with no value to return an empty string when parsing rath...
constructor(Qore::AbstractLineIterator li, *hash opts)
Creates the CsvIterator in single-type mode with general line iterator to read and an option hash...
The CsvFileWriter class for safe CSV file creation.
Definition: CsvUtil.qm.dox.h:1505
processCommonOptions(*hash opts, int C_OPTx)
process common options and and assing internal fields
auto getRecordList()
Returns the current record as a list.
prepareFieldsFromHeaders(*list headers)
match headers provided at csv header or in options, never called for multi-type because header_names ...
abstract writeRawLine(list values)
This method must be overridden in child classes to provide the output implementation.
auto memberGate(string name)
calls AbstractCsvIterator::memberGate()
hash< Qore::StatInfo > hstat()
Returns a StatInfo hash of the underlying file.
constructor(Qore::OutputStream output, *hash opts)
creates the CsvWriter in single-type mode with the OutputStream and an optional option hash ...
processSpec(hash spec)
process specification and assing internal data for resolving
constructor(AbstractLineIterator li, *hash opts)
creates the AbstractCsvIterator with an option hash in single-type mode
writeRawLine(list values)
renders the line and writes it to the output stream
bool next()
Moves the current line / record position to the next line / record; returns False if there are no mor...
const CSV_TYPE_SINGLE
Record type when multi-type is disabled.
Definition: CsvUtil.qm.dox.h:412
string getEncoding()
Returns the character encoding for the file.
hash getRecord()
Returns the current record as a hash.
int lineNumber()
Returns the current iterator line number in the file (the first line is line 1) or 0 if not pointing ...
writeRawLine(list values)
This method must be overridden in child classes to provide the output implementation.