* <code>$csv?names?*</code> returns the names of all fields (if available)
* Return enumerated strings for all records:
<syntaxhighlight pre lang="'xquery"'>
for $record at $pos in $csv?records
return $pos || ". " || string-join($record?*, ', ')
</syntaxhighlightpre>
The resulting representation consumes less memory than XML-based formats, and values can be directly accessed without conversion. Thus, it is recommendable for very large inputs and for efficient ad-hoc processing.
|- valign="top"
| {{Code|lax}}
| Specifies if a [[Conversion Module#Keys|lax approach is conversion rules]] are used to convert QNames to JSON names.
| {{Code|yes}}, {{Code|no}}
| {{Code|yes}}
|- valign="top"
| {{Code|skip-empty}}
| {{Announce|Version 11:}} Indicates if empty fields are included in the result. Only gets effective for the formats {{Code|direct}} or {{Code|attribute}}, and if the {{Code|header}} option is enabled. If Please note that if this option is enabled used and if the parsed data is serialized again, please note that the resulting CSV header may be incomplete.
| {{Code|yes}}, {{Code|no}}
| {{Code|no}}
'''Input''' {{Code|addressbook.csv}}:
<syntaxhighlight pre lang="xml">
Name,First Name,Address,City
Huber,Sepp,Hauptstraße 13,93547 Hintertupfing
</syntaxhighlightpre>
'''Query:'''
<syntaxhighlight pre lang="'xquery"'>
let $text := file:read-text('addressbook.csv')
return csv:parse($text, map { 'header': true() })
</syntaxhighlightpre>
'''Result:'''
<syntaxhighlight pre lang="xml">
<csv>
<record>
</record>
</csv>
</syntaxhighlightpre>
'''
'''Query:'''
<syntaxhighlight pre lang="'xquery"'>
let $options := map { 'lax': false() }
let $input := file:read-text('some-data.csv')
let $output := $input => csv:parse($options) => csv:serialize($options)
return $input eq $output
</syntaxhighlightpre>
'''Example 3:''' Converts CSV data to XQuery and returns distinct column values:
'''Query:'''
<syntaxhighlight pre lang="'xquery"'>
let $text := ``[Name,City
Jack,Chicago
)
)
</syntaxhighlightpre>
'''Result:'''
<syntaxhighlight pre lang="'xquery"'>
Distinct values:
* Name: Jack, John
* City: Chicago, Washington, New York
</syntaxhighlightpre>
=Errors=