Changes

Jump to navigation Jump to search
1,882 bytes added ,  23:22, 23 September 2013
Created page with "This XQuery Module contains a single function to parse CSV input. [http://en.wikipedia.org/wiki/Comma-separated_values CSV] (comma-separated values) is a popul..."
This [[Module Library|XQuery Module]] contains a single function to parse CSV input. [http://en.wikipedia.org/wiki/Comma-separated_values CSV] (comma-separated values) is a popular representation for tabular data, exported e. g. from Excel.

=Conventions=

All functions in this module are assigned to the {{Code|http://basex.org/modules/csv}} namespace, which is statically bound to the {{Code|csv}} prefix.<br/>
All errors are assigned to the {{Code|http://basex.org/errors}} namespace, which is statically bound to the {{Code|bxerr}} prefix.

=CSV Functions=

==csv:parse==
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|csv:parse|$input as xs:string|element(csv)}}<br/>{{Func|csv:parse|$input as xs:string, $options as item()|element(csv)}}
|-
| '''Summary'''
|Converts the CSV data specified by {{Code|$input}} to XML, and returns the result as {{Code|element(csv)}} value.<br/>The {{Code|$options}} argument can be used to control the way the input is converted. The following options are available:
* {{Code|separator}} defines the character which separates columns in a row. By default, this is a comma ({{Code|,}}).
* {{Code|headers}} specifies if the input contains a header row. The default value is {{Code|false}}.
Options can either be specified<br />
* as children of an {{Code|<csv:options/>}} element; e.g.:
<pre class="brush:xml">
<csv:options>
<csv:separator value=';'/>
...
</csv:options>
</pre>
* or as map, which contains all key/value pairs:
<pre class="brush:xquery">
{ 'key1' : 'value1', ... }
</pre>

|-
| '''Errors'''
|{{Error|BXCS0001|#Errors}} the specified separator must be a single character.
|}

=Errors=

{| class="wikitable" width="100%"
! width="110"|Code
|Description
|-
|{{Code|BXCS0001}}
| The specified separator must be a single character.
|}

=Changelog=

The module was introduced with Version 7.7.2.

[[Category:XQuery]]
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu