Serialize csv xquery map
The xqueryformat of CSV records as a sequence of arrays [1] is very useful when parsing but there seems to be no easy way to serialize from this format. Is this correct? map { "records": ["Huber", "Sepp", "Hauptstraße 13", "93547 Hintertupfing"], "names": ["Name", "First_Name", "Address", "City"] } =>csv:serialize() [SENR0001] Items of type map(xs:string, array(xs:string)) cannot be serialized. ... would be nice if it could. /Andy [1] http://docs.basex.org/wiki/CSV_Module#XQuery
Hi Andy, You can serialize the map by specifying the 'xquery' format as option: map { "records": ["Huber", "Sepp", "Hauptstraße 13", "93547 Hintertupfing"], "names": ["Name", "First_Name", "Address", "City"] } => csv:serialize(map { 'format': 'xquery', 'header': true() }) The result: Name,First_Name,Address,City Huber,Sepp,Hauptstraße 13,93547 Hintertupfing Cheers, Christian On Tue, May 29, 2018 at 4:43 PM, Andy Bunce <bunce.andy@gmail.com> wrote:
The xqueryformat of CSV records as a sequence of arrays [1] is very useful when parsing but there seems to be no easy way to serialize from this format. Is this correct?
map { "records": ["Huber", "Sepp", "Hauptstraße 13", "93547 Hintertupfing"], "names": ["Name", "First_Name", "Address", "City"] } =>csv:serialize()
[SENR0001] Items of type map(xs:string, array(xs:string)) cannot be serialized.
... would be nice if it could. /Andy
Ah, I thought I had tried that, but it is working now. Thanks /Andy On 29 May 2018 at 16:05, Christian Grün <christian.gruen@gmail.com> wrote:
Hi Andy,
You can serialize the map by specifying the 'xquery' format as option:
map { "records": ["Huber", "Sepp", "Hauptstraße 13", "93547 Hintertupfing"], "names": ["Name", "First_Name", "Address", "City"] } => csv:serialize(map { 'format': 'xquery', 'header': true() })
The result:
Name,First_Name,Address,City Huber,Sepp,Hauptstraße 13,93547 Hintertupfing Cheers, Christian
On Tue, May 29, 2018 at 4:43 PM, Andy Bunce <bunce.andy@gmail.com> wrote:
The xqueryformat of CSV records as a sequence of arrays [1] is very useful when parsing but there seems to be no easy way to serialize from this format. Is this correct?
map { "records": ["Huber", "Sepp", "Hauptstraße 13", "93547 Hintertupfing"], "names": ["Name", "First_Name", "Address", "City"] } =>csv:serialize()
[SENR0001] Items of type map(xs:string, array(xs:string)) cannot be serialized.
... would be nice if it could. /Andy
participants (2)
-
Andy Bunce -
Christian Grün