Pike v8.1 release 6

Method Parser.CSV()->parsehead()


Method parsehead

int parsehead(void|string delimiters, void|string|object matchfieldname)

Description

This function consumes the header-line preceding a typical comma, semicolon or tab separated value list and autocompiles a format description from that. After this function has successfully parsed a header-line, you can proceed with either fetchrecord() or fetch() to get the remaining records.

Parameter delimiters

Explicitly specify a string containing all the characters that should be considered field delimiters. If not specified or empty, the function will try to autodetect the single delimiter in use.

Parameter matchfieldname

A string containing a regular expression, using Regexp.SimpleRegexp syntax, or an object providing a Regexp.SimpleRegexp.match() single string argument compatible method, that must match all the individual fieldnames before the header will be considered valid.

Returns

It returns true if a CSV head has successfully been parsed.

See also

fetchrecord(), fetch(), compile()