csv:doc(), csv:parse() functions are not respecting the 'field-delimiter': 'tab' parameter

Friday, 18 July 2025 · 4 messages · last reply 21 Jul 2025
YK
Yitzhak Khabinsky18 Jul 2025 14:06 #
Hello, I am using BaseX 12.0 It seems that the csv:doc(), csv:parse() functions are not respecting the 'field-delimiter': 'tab' parameter. It emits the following error: [csv:parse] The value of 'field-delimiter' is not a single character: 'tab'. Though the old style parameter is working: 'separator': 'tab' It is documented here: https://docs.basex.org/main/CSV_Functions#options Repro is below. Failing XQuery =============== declare variable $csv_file as xs:string external := 'c:\path\to\input.txt'; declare variable $xml_file as xs:string external := 'c:\path\to\output.xml';
let $input_options := { 'header': false(), 'trim-whitespace': true(), 'field-delimiter': 'tab' }
let $output_options := {'indent': 'yes', 'method': 'xml', 'encoding': 'UTF-8'}
return csv:doc($csv_file, $input_options) -> file:write($xml_file, ., $output_options) Working XQuery =============== declare variable $csv_file as xs:string external := 'c:\path\to\input.txt'; declare variable $xml_file as xs:string external := 'c:\path\to\output.xml';
let $input_options := { 'header': false(), 'trim-whitespace': true(), 'separator': 'tab' }
let $output_options := {'indent': 'yes', 'method': 'xml', 'encoding': 'UTF-8'}
return csv:doc($csv_file, $input_options) -> file:write($xml_file, ., $output_options) Regards, Yitzhak Khabinsky
CG
Christian Grün21 Jul 2025 18:03 #
Thanks, Yitzhak, We’ll have to update the documentation. It’s probably best to use char('\t') instead of 'tab' in the future, or the ugly '	' alternative. Hope this helps, Christian
Quoted text · Yitzhak Khabinsky · 29 lines
Von: Yitzhak Khabinsky via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Gesendet: Freitag, 18. Juli 2025 14:06 An: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> Betreff: [basex-talk] csv:doc(), csv:parse() functions are not respecting the 'field-delimiter': 'tab' parameter Hello, I am using BaseX 12.0 It seems that the csv:doc(), csv:parse() functions are not respecting the 'field-delimiter': 'tab' parameter. It emits the following error: [csv:parse] The value of 'field-delimiter' is not a single character: 'tab'. Though the old style parameter is working: 'separator': 'tab' It is documented here: https://docs.basex.org/main/CSV_Functions#options Repro is below. Failing XQuery =============== declare variable $csv_file as xs:string external := 'c:\path\to\input.txt'; declare variable $xml_file as xs:string external := 'c:\path\to\output.xml'; let $input_options := { 'header': false(), 'trim-whitespace': true(), 'field-delimiter': 'tab' } let $output_options := {'indent': 'yes', 'method': 'xml', 'encoding': 'UTF-8'} return csv:doc($csv_file, $input_options) -> file:write($xml_file, ., $output_options) Working XQuery =============== declare variable $csv_file as xs:string external := 'c:\path\to\input.txt'; declare variable $xml_file as xs:string external := 'c:\path\to\output.xml'; let $input_options := { 'header': false(), 'trim-whitespace': true(), 'separator': 'tab' } let $output_options := {'indent': 'yes', 'method': 'xml', 'encoding': 'UTF-8'} return csv:doc($csv_file, $input_options) -> file:write($xml_file, ., $output_options) Regards, Yitzhak Khabinsky
YK
Yitzhak Khabinsky21 Jul 2025 19:26 #
Mr. Grun, Based on the suggestion, I tried both of them. 1) 'field-delimiter': '\t' is erroring out [csv:parse] The value of 'field-delimiter' is not a single character: '\t'. 2) 'field-delimiter': '&#9;' is working. IMHO, it is better to keep the 'tab' parameter like it was before. Regards, Yitzhak Khabinsky
CG
Christian Grün21 Jul 2025 19:39 #
1) 'field-delimiter': '\t' is erroring out [csv:parse] The value of 'field-delimiter' is not a single character: '\t'. char('\t') should work; see [1] for more details. Best, Christian [1] https://docs.basex.org/main/Standard_Functions#fn:char

⚡Generated with XQuery